坐标
<dependency>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
</dependency>
启动类加:
@EnableRetry
重试注解
@Retryable
就这么简单。实例代码
@EnableRetry
@SpringBootApplication
public class RetryApplication {
public static void main(String[] args) {
SpringApplication.run(RetryApplication.class, args);
}
}
@Slf4j
@Service
public class RetryService{
@Retryable(value = Exception.class, backoff = @Backoff(delay = 1000L),maxAttempts = 5)
public void retryMethod() throws Exception{
throw new Exception(e);
}
}
版权声明:本文为htydowd原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。