如何在中使用属性文件中的属性 @Backoff
自定义延迟时间注解?此属性仅接受常量作为值。我尝试初始化 someProperty
字段,但没有帮助,intellijidea显示一条消息:“属性值必须是常量”。
此代码无法编译:
public class SomeClass {
private final long someProperty;
public SomeClass (@Value("${someProperty}") Long someProperty) {
this.someProperty = someProperty;
}
@Retryable(value = RuntimeException.class, maxAttempts = 2,
backoff = @Backoff(delay = someProperty))
public SomeObject getSomeObject() {
return new SomeObject();
}
}
我能用吗 delayExpression
属性如下:
@Retryable(value = RuntimeException.class, maxAttempts = 2,
backoff = @Backoff(delayExpression = "${someProperty}"))
暂无答案!
目前还没有任何答案,快来回答吧!