对于一个用例,我们需要创建自定义注释,它将记录使用此注释注释的方法的返回值。输入参数很简单,但是如何创建返回值呢?
发布于 2017-10-09 11:25:12
使用@Around
并记录结果:
@Aspect
public class YourAspect {
@Around("@annotation(YourAnnotation) && execution(* *(..))")
public Object aroundAdvice(ProceedingJoinPoint joinPoint) throws Throwable {
Object returnObject = null;
try {
returnObject = joinPoint.proceed();
} catch (Throwable throwable) {
// You may want to log this
throw throwable;
}
// log returnObject here...
return returnObject;
}
}
https://stackoverflow.com/questions/46645220
复制相似问题