Eclipse Spring@AspectJ@Pointcut匹配,而不管参数列表如何
如何编写一个Spring@AspectJ切入点(Eclipse Spring@AspectJ@Pointcut匹配,而不管参数列表如何,eclipse,spring,aop,aspectj,pointcut,Eclipse,Spring,Aop,Aspectj,Pointcut,如何编写一个Spring@AspectJ切入点(@Pointcut)表达式来匹配类中的所有公共方法,而不管它们的参数列表如何 我想要一个方面,对于具有特定注释的特定类的所有公共方法,@MyAnnotation(类似于其他人想要的)。目前我的情况是这样的: @Aspect public final class ServiceDataAccessExceptionReporter { @Pointcut("execution(public * com.example.Service.*
@Pointcut
)表达式来匹配类中的所有公共方法,而不管它们的参数列表如何
我想要一个方面,对于具有特定注释的特定类的所有公共方法,@MyAnnotation
(类似于其他人想要的)。目前我的情况是这样的:
@Aspect
public final class ServiceDataAccessExceptionReporter {
@Pointcut("execution(public * com.example.Service.*(..)) && @annotation(com.example.MyAnnotation))")
public void annotatedMethod() {}
@AfterThrowing(pointcut = "annotatedMethod()", throwing = "exception")
public void reportException(final DataAccessException exception) {
...
}
}
Eclipse Spring插件指出(在源代码窗口中使用箭头注释)这是正确的建议方法com.example.Service.getNames()
。但它并不表示已经建议使用具有参数的方法,例如com.example.Service.getTimes(字符串名)
这是因为带有
@Pointcut
注释的方法没有参数吗?如何使切入点成为所有方法,而不考虑它们的参数列表?或者我必须为我的com.example.Service
类中的每种参数列表单独设置一个@Pointcut
?测试产生的WAR表明该方面实际上正在工作,并且我想要成为Pointcut的服务类的所有方法都是Pointcut
我的结论是,这实际上是Eclipse Spring插件中的一个缺陷:当@Pointcut
匹配多个位置时,它不会显示所有连接点,而是只显示一个连接点,这是它任意选择的