Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/376.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring重试-异常问题和重试_Java_Spring_Spring Boot_Exception_Spring Retry - Fatal编程技术网

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))