Dao类的Spring重试

Dao类的Spring重试,spring,spring-boot,jdbc,spring-data-jpa,connection-pooling,Spring,Spring Boot,Jdbc,Spring Data Jpa,Connection Pooling,我有下面的代码 Spring启动版本:2.3.4 @Repository class Dbrepository { public void performCall() { simpleJdbcCall = new SimpleJdbcCall(jdbcTemplate) .withProcedureName("read_actor") //..... simpleJ

我有下面的代码 Spring启动版本:2.3.4

@Repository
class Dbrepository
{


public void performCall() {

 simpleJdbcCall = new 
               SimpleJdbcCall(jdbcTemplate) 
               .withProcedureName("read_actor")
             //.....
  
    simpleJdbcCall.execute(...) ;
}

}
我想在每次调用之间以1分钟的间隔重试performCall()至少3次。 我怎样才能做到这一点?
我正在考虑使用Spring Retry?这是最好的方法吗?

您可以通过添加Spring Retry来实现它

   <dependency>
        <groupId>org.springframework.retry</groupId>
        <artifactId>spring-retry</artifactId>
    </dependency>

希望有用的

@enablerery
注释应该添加到他的
@Configuration
类中。将下面的bloc放在重试函数之外如何
simpleJdbcCall=new simpleJdbcCall(jdbcTemplate)。使用procedurename(“read_actor”)
我不理解你的问题,你说的外部是什么意思?他是否需要在每次重试时重新创建
simpleJdbcCall
?@M.Mas。我已经在另一个方法中使用了它code@A.khalifa我怎样才能只为数据库连接问题而重试,而不为其他问题重试。我应该提到哪个异常
@Retryable(maxAttempts=3,backoff=@Backoff(delay = 10000))
public void performCall() {

 simpleJdbcCall = new 
               SimpleJdbcCall(jdbcTemplate) 
               .withProcedureName("read_actor")
             //.....
  
    simpleJdbcCall.execute(...) ;
}