我研究了这个问题的答案@Recover methods are not triggered with @Retryable
但是我无法弄清楚为什么恢复方法不会在我的情况下运行。
@Service public MyRetryingService {
@Scheduled(fixedRate = 10 * 1000)
@Retryable(backoff = @Backoff(delay = 100, maxDelay = 101), maxAttempts = 3)
public void transferData() {
throw new IllegalArgumentException();
}
@Recover
public void recover(IllegalArgumentException exception) {
System.out.println("Recovering from a service down");
}
}
我得到了这个例外
org.springframework.retry.ExhaustedRetryException: Cannot locate recovery method; nested exception is java.lang.IllegalArgumentException
我在这里缺少什么?