然后创建一个测试重试的TestRetryService.java:
/**
-
@Author : JCccc
-
@CreateTime : 2019/8/16
-
@Description :
**/
public interface TestRetryService {
int dignifiedTest(int code) throws Exception;
}
然后是TestRetryServiceImpl.java:
import com.mail.elegant.service.TestRetryService;
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Recover;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Service;
import java.time.LocalTime;
/**
-
@Author : JCccc
-
@CreateTime : 2019/8/16
-
@Description :
**/
@Service
public class TestRetryServiceImpl implements TestRetryService {
@Override
@Retryable(value = Exception.class,maxAttempts = 3,b