我希望AOP记录方法的返回值
@After("execution(* com.dbs.tup.sample.service.*.*(..))")
public void logAfter(JoinPoint point) {
log.info("{} is returning {}", point.getSignature().getName(), "???");
}
答案 0 :(得分:1)
我发现了这个
@AfterReturning(pointcut = "execution(* com.dbs.tup.sample.service.*.*(..))", returning = "retValue")
public void logAfter(JoinPoint point, Object retValue) {
log.info("{} is returning {}", point.getSignature().getName(), (((MethodSignature) point.getSignature()).getReturnType().cast(retValue)).toString());
}