java – Spring AOP:@annotation(注释)

我(当然)试图使用许多我不太了解的结构来维护项目.在试图弄清楚 Spring中的AOP使用的过程中,我遇到了带有以下注释的方法

@Around(value =“@ annotation(annotation)”)

所以@Around意味着我们在AOP中执行方法切入点的’around’版本,我明白了.我不知道其他部分是什么意思. Spring文档提供以下内容

@annotation – limits matching to join points where the subject of the
join point (method being executed in Spring AOP) has the given
annotation

我不知道这意味着什么 – “在Spring AOP中执行的方法”听起来像建议的方法,但我不知道我(或Spring)如何找出建议的方法.听起来它是具有“给定注释”的方法,但如果是这样,那么给出了什么注释?

这个注释建议了哪些方法?还有什么意思呢?

解决方法

如果您有以下Spring Bean:
@Component
public class foo {

    @com.pkg.Bar      
    void fooMe() {
    }
}

然后是以下建议:

@Around("@annotation(com.pkg.Bar)")

将围绕fooMe(或使用@Bar注释的任何其他Spring bean方法)调用拦截

@Transactional注释就是一个很好的例子

相关文章

最近看了一下学习资料,感觉进制转换其实还是挺有意思的,尤...
/*HashSet 基本操作 * --set:元素是无序的,存入和取出顺序不...
/*list 基本操作 * * List a=new List(); * 增 * a.add(inde...
/* * 内部类 * */ 1 class OutClass{ 2 //定义外部类的成员变...
集合的操作Iterator、Collection、Set和HashSet关系Iterator...
接口中常量的修饰关键字:public,static,final(常量)函数...