我
通过 AspectJ 拦截方法。我需要在切入点表达式 execution(* *.*(..))
添加返回类型 TestObj。我怎样才能做到这一点?
@Around("@annotation(interceptor) && execution(* *.*(..)) && args(argType, ..)")
public Object logAction(ProceedingJoinPoint joinPoint, Interceptor interceptor, TestObj argType) throws Throwable {
// do smth
}
最佳答案
execution()
表达式支持返回类型过滤。如果您需要返回类型为 TestObj
或其任何子类型,则以下内容应该有效:
@Around("@annotation(interceptor) && execution(* TestObj *.*(..)) && args(argType, ..)")
public Object logAction(ProceedingJoinPoint joinPoint, Interceptor interceptor, TestObj argType) throws Throwable {
您可以找到更多in the official docs, Chapter 2. Annotations :
execution(public (@Immutable *) org.xyz..*.*(..))
The execution of any public method in a package with prefix org.xyz, where the method returns an immutable result.
关于java - spring aop执行返回类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49852625/