Attribute Value must be constant

到底是什么回事???

I have this in my class and I calling them from application.properties

Class A

 @Value("${maxAttempts}")
    private String maxAttempt;
    @Value("${delay}")
    private String delay;
    @Value("${multiplier}")
    private String multiplier;
    @Value("${max-delay}")
    private String maxDelay;

And I use them in this line

 @Retryable(maxAttempts=maxAttempt, value=RuntimeException.class, backoff = @Backoff(delay =delay,multiplier = multiplier, maxDelay = maxDelay))

application.properties

maxAttempt=3
delay=3
max-delay=9
multiplier=2

However I get Attribute Value must be constant

阅读 9.6k
1 个回答

注解里面的参数不能是变量,@Value是运行后才能取到的值。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题