3

I currently have a variable coming from a property file, declared as:

    @Value("${retryLimit}")
    private int retryLimit;

That I would like to use in an annotation instead of the hard-coded constant "3" in this case:

    @Retryable(maxAttempts = 3, backoff = @Backoff(delay = 2000))

Is this possible?

I've tried:

    @Retryable(maxAttempts = @Value("${retryLimit}"), backoff = @Backoff(delay = 2000))

However I get the following compile error:

"Incompatible types. Found: 'org.springframework.beans.factory.annotation.Value', required: 'int'"
WishIWasJeeping
  • 173
  • 2
  • 11

1 Answers1

1

No need to use @value inside another annotation tag. Just use with out @value. It will work.

@Retryable(maxAttempts = "${retryLimit}", backoff = @Backoff(delay = 2000))
theBittor
  • 786
  • 1
  • 11
  • 20
Raj
  • 21
  • 2