Spring-retry @Recover 方法仅在接口定义中有效

Spring-retry @Recover method works only in interface definition

我正在使用 spring-retry 为我的业务逻辑提供重试策略。我有接口和实现它的服务

public interface MyInterface {
    @Retryable(maxAttempts = 5, backoff = @Backoff(value = 0L))
    void doSth() throws Exception;

    @Recover
    void recoverIfFailed(Exception e);
}

@Service
public class MyService implements MyInterface {
    public void doSth() throws Exception {
            throw new Exception();
    }

    public void recoverIfFailed(Exception e) {
        System.out.println("Recovered!");
    }
}

在此配置中一切正常。但是我不明白为什么我不能像这样将 @Recovery 注释移动到接口实现:

@Service
public class MyService implements MyInterface {
    @Retryable(maxAttempts = 5, backoff = @Backoff(value = 0L)) // -- this is working
    public void doSth() throws Exception {
            throw new Exception();
    }

    @Recover // -- this is not working!
    public void recoverIfFailed(Exception e) {
        System.out.println("Recovered!");
    }
}

我真的不想在界面中公开我的恢复方法(因为这似乎是我的内部逻辑)但由于这个问题我不能。谁能告诉我什么是问题?

我提交了 open pull request to fix this.

作为变通方法,使用 @EnableRetry(proxyTargetClass = true)