【发布时间】:2018-11-20 16:54:01
【问题描述】:
我正在学习 SpringAOP,在运行基本程序时,我观察到 eclipse(当然是编译器)的奇怪行为。
当我在 @Pointcut 注释上练习时,我错误地在 Pointcut 表达式中添加了另一个括号。令人惊讶的是,我在运行时没有收到任何错误。加上它的作用就像魅力一样。它甚至不关心我在最后添加了多少个圆括号..如果我更改该表达式中的任何其他语法它会弹出一个错误..
这里是语法错误..
@Pointcut("execution(* com.kish.DAO.*.*(..))))))")
public void forPointcut() {}
我为@Before Advices 使用了切入点表达式引用。
@Before("forPointcut()")
public void beforeAddAccountant() {
System.out.println(" \n----->>>>> exceuting @Before advice before adding accountant");
}
@Before("forPointcut()")
public void otherLoggers() {
System.out.println("----->>>>> execution @Pointcut references before methods\n");
}
谁能告诉我这里发生了什么?
【问题讨论】:
-
@GhostCat 你太棒了..谢谢。
标签: java spring annotations spring-aop pointcut