添加Maven依赖:
<dependency> <groupId>org.springframework.retry</groupId> <artifactId>spring-retry</artifactId> <version>1.1.0.RELEASE</version> </dependency>
代码结构:
源码:
1 package Exception; 2 3 /** 4 * Created by zhengbin06 on 2017/2/14. 5 */ 6 public class Clazz { 7 private int i = 0; 8 public Student getStudent() throws SException { 9 if(++i != 3) { 10 System.out.println(i); 11 throw new SException(); 12 } 13 return new Student(); 14 } 15 }