arc*_*rcy 9 java aop spring annotations aspectj
我(当然)试图使用许多我不太了解的结构来维护项目.在试图弄清楚Spring中的AOP使用的过程中,我遇到了带有以下注释的方法:
@Around(value ="@ annotation(annotation)")
所以@Around意味着我们在AOP中执行方法切入点的'around'版本,我明白了.我不知道其他部分是什么意思.Spring文档提供以下内容:
@annotation - 限制连接点的匹配,其中连接点的主题(在Spring AOP中执行的方法)具有给定的注释
我不知道这意味着什么 - "在Spring AOP中执行的方法"听起来像建议的方法,但我不知道我(或Spring)如何找出建议的方法.听起来它是具有"给定注释"的方法,但如果是这样,那么给出了什么注释?
这个注释建议了哪些方法?还有什么意思呢?
Ori*_*Dar 15
如果您有以下Spring Bean:
@Component
public class foo {
@com.pkg.Bar
void fooMe() {
}
}
Run Code Online (Sandbox Code Playgroud)
然后是以下建议:
@Around("@annotation(com.pkg.Bar)")
Run Code Online (Sandbox Code Playgroud)
将调用拦截器fooMe(或任何其他注释的Spring bean方法@Bar)
该@Transactional注释是一个很好的例子
| 归档时间: |
|
| 查看次数: |
16721 次 |
| 最近记录: |