Aspectj切入点不适用于Spring Boot 2中的spring @Recover方法

问题描述 投票:0回答:1

我在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
1个回答
0
投票

两个建议都可能具有precedence(相同)

© www.soinside.com 2019 - 2024. All rights reserved.