Fix BeanCurrentlyInCreationException in Spring Applications
Understand the two causes of BeanCurrentlyInCreationException, a true dependency cycle and an early reference that later got wrapped in a proxy.

BeanCurrentlyInCreationException means Spring was asked for a bean that it was still in the middle of building. The message is blunt ("Error creating bean with name 'orderService': Requested bean is currently in creation: Is there an unresolvable circular reference?"), and it has two quite different causes. One is the ordinary dependency cycle that constructor injection cannot satisfy. The other is subtler: a bean that got injected in its raw form and was later wrapped in a proxy, so what one bean holds is not what the container finally registered. This post separates the causes, shows the fix for each and a way to find the ring in a large application. It applies to Spring Framework 6 and 7 with Spring Boot 3.5 and 4.
What the error looks like
org.springframework.beans.factory.BeanCurrentlyInCreationException:
Error creating bean with name 'orderService': Requested bean is currently in creation:
Is there an unresolvable circular reference or an asynchronous initialization dependency?The bean named in the message is the one Spring was building when it was requested again. The stack trace, and the "UnsatisfiedDependencyException" chain around it, lists the beans in the order of creation. Read it from the bottom: the last entry before the repeat is the bean that asked for the one being created.
Cause 1: a constructor cycle
@Service
class OrderService {
OrderService(InventoryService inventory) { /* ... */ }
}
@Service
class InventoryService {
InventoryService(OrderService orders) { /* ... */ }
}To construct OrderService, Spring needs an InventoryService; to construct that, it needs an OrderService, which is not finished. With constructor injection nothing can break the loop, because neither object can exist before the other. In Spring Boot 2.6 and later, circular references are also prohibited by default for setter and field injection, so the failure appears at startup as the better-formatted "dependencies form a cycle" report described in circular dependency errors. The exception named here is what you see in older projects, in contexts built outside Boot, and in the second cause.
The fixes are design changes: extract the shared behaviour into a third bean, publish an event in place of a direct call, or split a bloated service along its use cases. They are laid out in the linked post. @Lazy on one constructor parameter gives a proxy and breaks the ring at startup, as a stopgap.
Cause 2: the raw version that got wrapped
This one confuses people because the cycle is allowed and the exception appears anyway. Allow circular references (spring.main.allow-circular-references=true, or an older Spring) and Spring resolves a setter or field cycle by exposing an early reference to the half-built bean. If the bean is later wrapped by a post-processor, for instance a proxy for @Async, @Transactional or @Cacheable, the early reference that another bean already holds is the unwrapped object, which is not the same as the final bean. Spring detects the mismatch and throws:
BeanCurrentlyInCreationException: Error creating bean with name 'reportService':
Bean with name 'reportService' has been injected into other beans [mailer] in its raw version
as part of a circular reference, but has eventually been wrapped. This means that said other
beans do not use the final version of the bean.The reason for the error is a correctness one. mailer would call reportService methods on the raw object, bypassing the transaction or async behaviour, so the annotations would silently not apply to those calls. Spring refuses to leave you with that.
Two classic triggers: an @Async method on a bean that is part of a cycle, and @Transactional on a bean whose proxy is created late because of a BeanPostProcessor ordering issue. The fixes, in order of preference:
Remove the cycle. This is the only fix that leaves no trap behind.
Inject lazily. Put @Lazy on the injection point in the bean that holds the raw reference, so it receives a proxy that resolves the final bean on first use.
@Service
class Mailer {
private final ReportService reports;
Mailer(@Lazy ReportService reports) { this.reports = reports; }
}Move the annotated method to another bean that is not in the ring, so the bean in the cycle needs no proxy. An @Async method in a small AsyncRunner bean, called by the others, is a common shape. The proxy limits and self-calls are explained in self-invocation.
Do not use @DependsOn to hide it. It orders creation and does not remove the cycle.
Cause 3: a lifecycle callback that reaches back
A bean can also ask for a bean that is in creation through a callback, before the first one has finished initialising:
@Component
class CacheWarmer {
@Autowired ApplicationContext context;
@PostConstruct
void warm() {
context.getBean(ProductService.class).loadAll(); // ProductService may be in creation
}
}If ProductService depends on CacheWarmer, directly or through others, then @PostConstruct of the warmer runs while the container is still building the ring. The same happens with a @Bean method that calls getBean, a FactoryBean that looks up its target, and a BeanFactoryPostProcessor that instantiates beans early (which also loses post-processing for them and logs "is not eligible for getting processed by all BeanPostProcessors"). Move the work to after startup: listen for ApplicationReadyEvent or implement SmartInitializingSingleton, which runs after all singletons are created, as laid out in PostConstruct and its alternatives. Look up beans lazily, with ObjectProvider<ProductService> and getObject() at the time of use, not in the constructor.
How to find the ring
In a small application the stack trace is enough. In a large one, with forty beans in the chain, find it mechanically.
Start the application with debug output for the creation order: logging.level.org.springframework.beans.factory.support.DefaultListableBeanFactory=DEBUG prints "Creating shared instance of singleton bean" for each bean, and the repeat shows where the loop closes. The Boot report from --debug also lists conditions. The UnsatisfiedDependencyException chain in the stack trace already names each hop (via constructor parameter 0), so copy it into a text file and draw the ring on paper: the beans and arrows usually reveal one edge that is the weakest, such as a service calling a notifier which calls the service back to read a flag.
Prefer to cut the edge that carries the least behaviour. If Notifier only needs the flag, pass the flag, or inject a small FeatureFlags bean that both depend on. To prevent new rings, an ArchUnit rule against package cycles catches many of them before they become bean cycles.
For general startup failures that are not cycles, the checklist is in application failed to start, and the mechanics of how the container builds beans are in how the Spring container works.
Where this does not apply
If the message says "currently in creation" for a prototype-scoped bean, the cycle goes through prototypes, which Spring never resolves early, and the cause is the same constructor cycle with a different scope. A @Configuration class that injects a bean it defines itself, through a non-static @Bean method on the class, can trigger the error too; make that @Bean method static. The semantics are described in the factory collaborators section of the reference and the exception in the Spring Javadoc.


