Jan 23rd, 2013, 03:28 PM
How to avoid temporary circular dependencies?
We have a severe problem with application context creation. At a certain degree of complexity in our application context (in terms of the number of the beans that must be autowired), arbitrary beans are not fully initialized any more. We run into NullPointerExceptions when we access properties of these beans.
The result of the debugging session: For autowiring by type Spring tries to initialize hundreds of factory beans just to find out the type of the objects these beans create. This leads to temporary circular dependencies. We guess this is part of the abovementioned problem and would to like to avoid these circular dependencies. If we could give Spring a hint about the type of the objects the factory create, we could avoid these temporary circular dependencies entirely.
How can we give Spring a hint about the type of the objects that are created by the factory beans?
We use Spring 3.1.2.RELEASE with XML configuration and component scan.