Understanding Spring context initialization order?

Best solution would simply be to take out the circular dependency; I have not yet encountered a scenario where such a structure was warranted. But if you do want to stick with it then perhaps your above problem is due to the fact that you have constructor injection somewhere.

Best solution would simply be to take out the circular dependency; I have not yet encountered a scenario where such a structure was warranted. But if you do want to stick with it then perhaps your above problem is due to the fact that you have constructor injection somewhere: Circular dependencies If you are using predominantly constructor injection it is possible to write and configure your classes and beans such that an unresolvable circular dependency scenario is created. Consider the scenario where you have class A, which requires an instance of class B to be provided via constructor injection, and class B, which requires an instance of class A to be provided via constructor injection.

If you configure beans for classes A and B to be injected into each other, the Spring IoC container will detect this circular reference at runtime, and throw a BeanCurrentlyInCreationException. One possible solution to this issue is to edit the source code of some of your classes to be configured via setters instead of via constructors. Another solution is not to use constructor injection and stick to setter injection only.In other words, while it should generally be avoided in all but the rarest of circumstances, it is possible to configure circular dependencies with setter injection.

Unlike the typical case (with no circular dependencies), a circular dependency between bean A and bean B will force one of the beans to be injected into the other prior to being fully initialized itself (a classic chicken/egg scenario).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions