Our application uses extensively uses Spring Beans, we randomly see application startup error saying that there is Circular Bean Dependency. But this error doesn't occur always, but is instead random across multiple restarts. What could be the reason for randomness here ? If there is a Circular Dependency why it doesn't consistently fail / succeed ?
Exception: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name ‘x’: Requested bean is currently in creation: Is there an unresolvable circular reference?
Spring starts the process of initializing beans and gets to know of Circular reference in the process. Depending on whether constructor based or member based auto wiring is used, circular reference may or may not be successful. If two classes involved in Circular Dependency Chain uses Constructor autowiring or member autowiring below scenarios could occur :
So, if you have Circular Dpendency and autowiring falls in category (2), you may observe randomly succeeding / failing circular dependency resolution.
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