Spring AOP切入点表达式以排除注释

时间:2016-05-12 00:33:55

标签: java spring aop

我正在尝试创建一个切入点表达式,该表达式将触发某个包中的所有方法,但不会基于自定义注释触发。到目前为止,这是我第一次执行而不是第二次执行。谢谢你的帮助!

@AfterThrowing(pointcut = "execution(* services..*.*(..)) && !within(@services.annotation.IgnoreBusinessServiceExceptionTranslation *)", throwing = "ex") 

public void exceptionThrown( Throwable ex ){}

接口:

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface IgnoreBusinessServiceExceptionTranslation
{}

1 个答案:

答案 0 :(得分:3)

为其他人找到答案!

@AfterThrowing(pointcut = "execution(* services..*.*(..)) && !@annotation(services.annotation.IgnoreBusinessServiceExceptionTranslation)", throwing = "ex") 

public void exceptionThrown( Throwable ex ){}
相关问题