![](/img/trans.png)
[英]Can I use another Annotation as the value of the Spring @Qualifier?
[英]Can I use a Spring @Value variable from properties in another annotation?
我目前有一個來自屬性文件的變量,聲明為:
@Value("${retryLimit}")
private int retryLimit;
在這種情況下,我想在注釋中使用而不是硬編碼常量“3”:
@Retryable(maxAttempts = 3, backoff = @Backoff(delay = 2000))
這可能嗎?
我試過了:
@Retryable(maxAttempts = @Value("${retryLimit}"), backoff = @Backoff(delay = 2000))
但是我收到以下編譯錯誤:
"Incompatible types. Found: 'org.springframework.beans.factory.annotation.Value', required: 'int'"
無需在另一個注釋標簽中使用@value
。 只需使用@value
。 它會起作用。
@Retryable(maxAttempts = "${retryLimit}", backoff = @Backoff(delay = 2000))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.