Closed pop1213 closed 1 month ago
Note that eager initialization refers to the "factory-bean" as the bean containing the factory method - which may be in turn an implementation of the FactoryBean
interface. Only in such a scenario where it needs to be initialized in order to have a reliable factory method to introspect, it will initialize that target bean then. However, it will not perform eager calls to a factory method just to find out whether the runtime bean instance produced by it has a more specific type than what the method return type declares, and it also won't invoke constructors of factory beans if the method signature indicates the type already. I'll revise the getBeanNamesForType
javadoc to be more specific about the actual effect there.
Spring version: 6.0.16
This is the documentation for the
ListableBeanFactory#getBeanNamesForType
method.According to the documentation of the
getBeanNamesForType
method, the beanmyBeanCreater
should be eagerly initialized. However, in the following test it was not.beans.xml:
Test: