Suppose I have a bean which depends on another bean, and another bean depends on first bean.
Bean#1 -> Bean#2 -> Bean#1
How can I resolve this issue?
This is from Spring Reference
You can generally trust Spring to do the right thing. It detects configuration problems, such as references to non-existent beans and circular dependencies, at container load-time. Spring sets properties and resolves dependencies as late as possible, when the bean is actually created.
So it instantiates both beans and injects them onto each other.
In your case BeanCurrentlyInCreationException
mostly arose due to constructor injection. If that is the case mostly using setter injection instead of constructor injection will solve the issue. Constructor injection typically gives rise to the chicken-egg problem!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With