gpt4 book ai didi

java - Spring AOP切入点表达式排除注解

转载 作者:行者123 更新时间:2023-11-29 04:45:59 26 4
gpt4 key购买 nike

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

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

public void exceptionThrown( Throwable ex ){}

接口(interface):

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

最佳答案

找到其他人的答案!

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

public void exceptionThrown( Throwable ex ){}

关于java - Spring AOP切入点表达式排除注解,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37175394/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com