Java Spring重试-异常问题和重试
我们如何在同一块Java Spring重试-异常问题和重试,java,spring,spring-boot,exception,spring-retry,Java,Spring,Spring Boot,Exception,Spring Retry,我们如何在同一块@Retryable方法中捕获两个不同的异常(例如来自.lang和.io包)。一个是返回一个IOException,另一个是重试该方法 @Retryable(value = {Exception.calss } ,maxAttempts = 3, backoff = @Backoff(delay = 3000)) public String getInfo() { try { //here we have an executive code that ma
@Retryable
方法中捕获两个不同的异常(例如来自.lang
和.io
包)。一个是返回一个IOException
,另一个是重试该方法
@Retryable(value = {Exception.calss } ,maxAttempts = 3, backoff = @Backoff(delay = 3000))
public String getInfo() {
try {
//here we have an executive code that may have an IOException
} catch(Exception ex) {
//And here i would catch the Exception
throw new Exception();
}
}
可以使用注释的参数来处理多个异常:
@Retryable(
include = { java.lang.IllegalAccessException.class, java.io.IOException.class },
maxAttempts = 3,
backoff = @Backoff(delay = 3000))