小编use*_*543的帖子

如何设置Spring Retry模板重试最大尝试次数:无限

我想用Spring Retry修改数据库连接的创建,以便在应用程序启动时数据库关闭时再试一次。我不想限制重试次数。我应该如何配置策略来做到这一点。

我当前的代码(我知道在这种状态下它限制为100):

SimpleRetryPolicy policy = new SimpleRetryPolicy(100, Collections.singletonMap(Exception.class, true));

// Use the policy...
RetryTemplate template = new RetryTemplate();
template.setRetryPolicy(policy);
Connection conn = template.execute(new RetryCallback<Connection, Exception>() {
    public Connection doWithRetry(RetryContext context) throws Exception {
        return getConnectionFactory().createConnection();
    }
});
Run Code Online (Sandbox Code Playgroud)

我应该如何修改此代码?

java spring multithreading jdbc spring-retry

4
推荐指数
1
解决办法
1886
查看次数

Java Cucumber 无法识别我的字符串参数

Cucumber 无法识别 String 参数,我想将其用作货币。它只识别 int 值。(它找到步骤,因为其他步骤有效)

@When("I deposit {int} of {string}")
public void testDeposit(int value, String currency) throws ClientProtocolException, IOException {
Run Code Online (Sandbox Code Playgroud)

它显示以下错误消息:

There were undefined steps. You can implement missing steps with the snippets below:

@When("I deposit {int} of GBP")
public void i_deposit_of_GBP(Integer int1) {
    // Write code here that turns the phrase above into concrete actions
    throw new cucumber.api.PendingException();
}

@Then("My balance is {int} of GBP")
public void my_balance_is_of_GBP(Integer int1) {
    // Write code here that turns the phrase …
Run Code Online (Sandbox Code Playgroud)

java junit cucumber cucumber-junit cucumber-java

3
推荐指数
1
解决办法
2300
查看次数