Spring的default-lazy-init 与 lazy-init

来源:互联网 发布:知秋新书 编辑:程序博客网 时间:2024/05/22 20:28

在同一个文件中<bean />里面设置的优先级大于<beans />里设置的优先级:

 

 

如果在一个spring配置文件中引入另外的配置文件,如:<import resource="classpath:beanss.xml"/>

则以被引入文件(beanss.xml)中设置的<beans />里的设置为准,与引入文件中的设置无关。

 

 

 

One thing to understand about lazy-initialization is that even though a bean definition may be marked up as being lazy-initialized, if the lazy-initialized bean is the dependency of a singleton bean that is not lazy-initialized, when the ApplicationContext is eagerly pre-instantiating the singleton, it will have to satisfy all of the singletons dependencies, one of which will be the lazy-initialized bean! So don't be confused if the IoC container creates one of the beans that you have explicitly configured as lazy-initialized at startup; all that means is that the lazy-initialized bean is being injected into a non-lazy-initialized singleton bean elsewhere.

 

 

 

 

 

原创粉丝点击