Spring / Spring Retry Interview Questions
How do you configure Spring Retry using application properties in Spring Boot?
Spring Retry itself does not directly read application.properties — its configuration is annotation or bean-driven. However, Spring Boot's auto-configuration for retry integrates with property placeholders, allowing you to externalize retry parameters using Spring Expression Language (SpEL) references in annotations.
Externalizing retry parameters via properties:
# application.properties
retry.maxAttempts=5
retry.delay=2000
retry.multiplier=1.5@Retryable(
retryFor = Exception.class,
maxAttemptsExpression = "${retry.maxAttempts}",
backoff = @Backoff(
delayExpression = "${retry.delay}",
multiplierExpression = "${retry.multiplier}"
)
)
public void callApi() { ... }This approach lets you change retry behavior per environment without recompiling. The attributes that accept SpEL expressions are: maxAttemptsExpression, delayExpression, maxDelayExpression, multiplierExpression, and randomExpression.
Note that when using SpEL expressions in annotations, the annotation attributes ending in Expression must be used — not the plain numeric ones. Mixing both (e.g., setting both maxAttempts and maxAttemptsExpression) will result in a compilation or runtime error.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
