在spring引導應用程序中,我在yaml文件中定義了一些配置屬性,如下所示。如何將Spring Boot中的配置屬性注入到Spring Retry註釋中?
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
春重試標註值是多少?在下面的示例中,我想將maxAttempts的值10
和退避值的500L
替換爲config屬性的相應引用。
@Retryable(maxAttempts=10, include=TimeoutException.class, [email protected](value = 500L))