Java springaop执行返回类型
我 通过AspectJ拦截方法。我需要在切入点表达式Java springaop执行返回类型,java,spring,aop,aspectj,Java,Spring,Aop,Aspectj,我 通过AspectJ拦截方法。我需要在切入点表达式执行(**.*(..)中添加返回类型TestObj。我该怎么做 @Around("@annotation(interceptor) && execution(* *.*(..)) && args(argType, ..)") public Object logAction(ProceedingJoinPoint joinPoint, Interceptor interceptor, TestObj argType
执行(**.*(..)
中添加返回类型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 {
你可以找到更多:
执行(public(@Immutable*)org.xyz.**(.)
在前缀为org.xyz的包中执行任何公共方法,其中该方法返回一个不可变的结果
第一个方法参数的类型是否与返回类型一样也是
TestObj
?或者这是一个错误,您实际上想要将返回值绑定到一个参数?因为args()。我尝试执行(TestObj**(..),但acpect不拦截我的函数