在 Spring Boot 应用程序中,我在 yaml 文件中定义了一些配置属性,如下所示。
my.app.maxAttempts = 10
my.app.backOffDelay = 500L
还有一个茶豆的例子
@ConfigurationProperties(prefix = "my.app")
public class ConfigProperties {
private int maxAttempts;
private long backOffDelay;
public int getMaxAttempts() {
return maxAttempts;
}
public void setMaxAttempts(int maxAttempts) {
this.maxAttempts = maxAttempts;
}
public void setBackOffDelay(long backOffDelay) {
this.backOffDelay = backOffDelay;
}
public long getBackOffDelay() {
return backOffDelay;
}
我该如何将my.app.maxAttempts
和my.app.backOffdelay
的值注入到Spring Retry注释中? 在下面的示例中,我希望使用配置属性对应的引用替换maxAttempts的值10
和backoff值500L
。
@Retryable(maxAttempts=10, include=TimeoutException.class, backoff=@Backoff(value = 500L))
解析一个有效表达式后,表达式中仍有更多数据:'lcurly({)'
的错误提示。 - Baptiste Pernet