Springboot retryable not retrying
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
When @Retryable does not retry in Spring Boot, the most common causes are: missing @EnableRetry annotation, the spring-retry dependency not on the classpath, calling the retryable method from within the same class (bypassing the proxy), or the wrong exception type being thrown. The @Retryable annotation works through Spring AOP proxying — the method must be called on a Spring-managed bean from another bean for the retry interceptor to trigger.
Basic Working Setup
Cause 1: Missing @EnableRetry
The most common cause. Without @EnableRetry, the @Retryable annotation is ignored:
Cause 2: Missing Dependencies
Both spring-retry and spring-boot-starter-aop are required:
Without spring-boot-starter-aop, the AOP proxy that intercepts the method call is not created.
Cause 3: Self-Invocation (Same Class Call)
Calling a @Retryable method from within the same class bypasses the Spring proxy:
Fix: inject the bean into itself or move the retryable method to a separate service:
Cause 4: Wrong Exception Type
@Retryable only retries for the specified exception types:
Cause 5: Method Visibility
@Retryable only works on public methods (Spring AOP limitation with default proxies):
Cause 6: @Recover Method Mismatch
The @Recover method must match the return type and exception type:
Verifying Retry Works
Common Pitfalls
- Calling
@Retryablemethod from the same class: Spring AOP uses proxies that only intercept external method calls. When method A calls method B in the same class, B's@Retryableis bypassed. Move the retryable method to a separate@Servicebean. - Missing
spring-boot-starter-aopdependency:spring-retryalone is not enough. Without the AOP starter, Spring cannot create the proxy that intercepts method calls. Bothspring-retryandspring-boot-starter-aopmust be on the classpath. @Recovermethod signature mismatch: The recovery method must have the same return type as the retryable method, take the exception as the first parameter, and take the same additional parameters in the same order. A mismatch causes Spring to silently skip the recovery method.- Using
@Retryableonfinalorstaticmethods: Spring's default proxy-based AOP cannot interceptfinalorstaticmethods. If you need retry on afinalmethod, switch to AspectJ weaving by setting@EnableRetry(proxyTargetClass = true)or use compile-time weaving. - Not specifying
retryFor(relying on defaults): WithoutretryFor,@Retryableretries on anyExceptionbut notError. If your method throws a checked exception that you expect to be retried, explicitly listing it inretryFormakes the intent clear and avoids accidentally retrying non-transient exceptions.
Summary
- Always add both
@EnableRetryand thespring-retry+spring-boot-starter-aopdependencies - Never call a
@Retryablemethod from within the same class — Spring's proxy cannot intercept self-invocations - Ensure the exception thrown matches the
retryForexception type - Make retryable methods
publicand non-finalfor proxy-based AOP to work - Match
@Recovermethod signatures exactly: same return type, exception first, then original parameters
Related reading
- springboot swagger3 Failed to load remote configuration.
- SpringBoot Unable to find a single main class from the following candidates
- Springboot Wildfly 10 deployment error jdk.unsupported module not found
- SpringBoot with LogBack creating LOG_PATH_IS_UNDEFINED folder
- springboot Upgrade from 2.3.5.RELEASE to 2.4.1- ClassNotFoundException org.springframework.boot.context.properties.ConfigurationBeanFactoryMetadata
- Springfox 3.0.0 is not working with Spring Boot 2.6.0
- SpringBoot's MultipartConfig maxFileSize not taking effect
- SpringBootTest No qualifying bean of type 'org.springframework.test.web.servlet.MockMvc' available

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.