我在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处设置了演示代码
两个建议都可能具有precedence的(相同)