关于Spring的延迟加载无效的问题

spring的延迟加载可以设置default-lazy-init="true"不让容器在启动的时候实例化所有的bean对象,但在项目中我使用了这个属性没有任何作用,我的spring配置文件是通过一个主配置文件import 4个resource配置文件组成的,可是所有的文件中都设置了default-lazy-init="true",仍然在启动的时候实例化所有的bean,不知道为什么?
这是主配置文件的设置:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"
    default-lazy-init="true">
这是导入的配置文件,里面每个beans标签也设置了default-lazy-init="true"
<!-- 引入其他spring文件 -->
   
<import resource="applicationContext-dao.xml"/>  
<import resource="applicationContext-service.xml"/>
<import resource="applicationContext-dwr.xml" />
<import resource="applicationContext-action.xml" />
这是启动以后的信息,最后一句貌似就是实例化所有bean了
信息: Initializing Spring root WebApplicationContext
[INFO] ContextLoader - Root WebApplicationContext: initialization started
[INFO] XmlWebApplicationContext - Refreshing org.springframework.web.context.support.XmlWebApplicationContext@18e4327: display name [Root WebApplicationContext]; startup date [Thu Jul 02 10:52:20 CST 2015]; root of context hierarchy
[INFO] XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
[INFO] XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext-dao.xml]
[INFO] XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext-service.xml]
[INFO] XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext-dwr.xml]
[INFO] XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext-action.xml]
[INFO] XmlWebApplicationContext - Bean factory for application context [org.springframework.web.context.support.XmlWebApplicationContext@18e4327]: org.springframework.beans.factory.support.DefaultListableBeanFactory@26f9e5
[INFO] PropertyPlaceholderConfigurer - Loading properties file from class path resource [config.properties]
[INFO] XmlWebApplicationContext - Bean 'org.springframework.aop.config.internalAutoProxyCreator' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[INFO] XmlWebApplicationContext - Bean 'org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[INFO] DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@26f9e5: defining beans

[propertyConfigurer,dataSource,sessionFactory,timeoutAspect,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.aop.aspectj.AspectJPointcutAdvisor,timeoutcut,txManager,txAdvice,org.springframework.aop.support

猜你喜欢

转载自jarniyy.iteye.com/blog/2223755