加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – Spring AOP:@annotation(注释)

发布时间:2020-12-15 02:51:38 所属栏目:Java 来源:网络整理
导读:我(当然)试图使用许多我不太了解的结构来维护项目.在试图弄清楚 Spring中的AOP使用的过程中,我遇到了带有以下注释的方法: @Around(value =“@ annotation(annotation)”) 所以@Around意味着我们在AOP中执行方法切入点的’around’版本,我明白了.我不知道其
我(当然)试图使用许多我不太了解的结构来维护项目.在试图弄清楚 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注释就是一个很好的例子

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读