【发布时间】:2019-10-25 17:47:37
【问题描述】:
我在 spring boot 2.1.1 中使用 aop,我有切入点并建议记录调用并返回使用自定义注释 @LogAround 注释的方法的值
@Pointcut("@annotation(x.y.z.LogAround)")
public void logAroundJoinPoint() {}
@Before("logAroundJoinPoint()")
public void logBefore(JoinPoint joinPoint) {
// logging code
}
@AfterReturning(
pointcut = "logAroundJoinPoint()",
returning= "result")
public void logAfterReturning(JoinPoint joinPoint, Object result) {
//some logging code
}
对于使用@LogAround 注释的方法,此代码按预期记录方法调用除非我在使用@Recover 注释的方法上使用以进行春季重试!
我不知道为什么会这样。
一种选择是使用恢复方法进行简单的日志记录,但如果有办法使这项工作正常进行,我更愿意。任何帮助表示赞赏。
我在git_demo_code有设置演示代码
【问题讨论】:
标签: spring spring-boot spring-aop spring-retry