我在用 spring boot 做 spring-retry 时发现了一个问题。类实现接口时,超过最大重试次数后无法进入@recover方法。但是当我注入一个普通的类时,我可以进入这个方法。您的及时帮助和善意的建议将不胜感激,谢谢!
当我这样做时,我可以进入@Recover 方法
@Service
public class TestService {
@Retryable(Exception.class)
public String retry(String c) throws Exception{
throw new Exception();
}
@Recover
public String recover(Exception e,String c) throws Exception{
System.out.println("got error");
return null;
}
}
但是一旦类实现了另一个接口,它就不起作用了
@Service
public class TestService implements TestServiceI{
@Override
@Retryable(Exception.class)
public String retry(String c) throws Exception{
throw new Exception();
}
@Recover
public String recover(Exception e,String c) throws Exception{
System.out.println("got error");
return null;
}
}
蓝山帝景
猛跑小猪
aluckdog
随时随地看视频慕课网APP
相关分类