gpt4 book ai didi

java - Spring Retry - 异常问题和重试

转载 作者:行者123 更新时间:2023-12-01 14:21:04 25 4
gpt4 key购买 nike

我们如何在 .lang 的同一块中捕获两个不同的异常(例如来自 .io@Retryable 包)方法。一,我们返回一个 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();
}
}

最佳答案

您可以使用 include 处理多种异常的注解参数:

@Retryable(
include = { java.lang.IllegalAccessException.class, java.io.IOException.class },
maxAttempts = 3,
backoff = @Backoff(delay = 3000))

关于java - Spring Retry - 异常问题和重试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61141431/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com