当服务器启动 Spring 为什么会加载两次
3个回答
展开全部
看看生命周期代码对不对
还有webxml
还有webxml
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
案例:
2009-07-23 12:06:28,828 INFO [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]] - Initializing Spring root WebApplicationContext
2009-07-23 12:06:28,828 INFO [org.springframework.web.context.ContextLoader] - Root WebApplicationContext: initialization started
2009-07-23 12:06:28,984 INFO [org.springframework.web.context.support.XmlWebApplicationContext] - Refreshing org.springframework.web.context.support.XmlWebApplicationContext@23d275: display name [Root WebApplicationContext]; startup date [Thu Jul 23 12:06:28 CST 2009]; root of context hierarchy
2009-07-23 12:06:29,250 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
2009-07-23 12:06:30,437 INFO [org.springframework.web.context.support.XmlWebApplicationContext] - Bean factory for application context [org.springframework.web.context.support.XmlWebApplicationContext@23d275]: org.springframework.beans.factory.support.DefaultListableBeanFactory@24ea85
2009-07-23 12:06:30,593 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@24ea85: defining beans [initdb]; root of factory hierarchy
2009-07-23 12:06:31,312 INFO [org.apache.torque.Torque] - TorqueInit Success
2009-07-23 12:06:31,421 INFO [org.springframework.web.context.ContextLoader] - Root WebApplicationContext: initialization completed in 2593 ms
2009-07-23 12:06:31,906 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts-default.xml]
2009-07-23 12:06:32,515 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts-plugin.xml]
2009-07-23 12:06:32,562 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts.xml]
2009-07-23 12:06:33,062 INFO [org.apache.struts2.spring.StrutsSpringObjectFactory] - Initializing Struts-Spring integration...
2009-07-23 12:06:33,062 INFO [com.opensymphony.xwork2.spring.SpringObjectFactory] - Setting autowire strategy to name
2009-07-23 12:06:33,062 INFO [org.apache.struts2.spring.StrutsSpringObjectFactory] - ... initialized Struts-Spring integration successfully
2009-07-23 12:06:35,796 INFO [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/PurchaseDemo]] - Initializing Spring root WebApplicationContext
2009-07-23 12:06:35,796 INFO [org.springframework.web.context.ContextLoader] - Root WebApplicationContext: initialization started
2009-07-23 12:06:35,968 INFO [org.springframework.web.context.support.XmlWebApplicationContext] - Refreshing org.springframework.web.context.support.XmlWebApplicationContext@ff0d4b: display name [Root WebApplicationContext]; startup date [Thu Jul 23 12:06:35 CST 2009]; root of context hierarchy
2009-07-23 12:06:36,234 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
2009-07-23 12:06:38,046 INFO [org.springframework.web.context.support.XmlWebApplicationContext] - Bean factory for application context [org.springframework.web.context.support.XmlWebApplicationContext@ff0d4b]: org.springframework.beans.factory.support.DefaultListableBeanFactory@c6b8b0
2009-07-23 12:06:38,203 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@c6b8b0: defining beans [initdb]; root of factory hierarchy
2009-07-23 12:06:38,968 INFO [org.apache.torque.Torque] - TorqueInit Success
2009-07-23 12:06:39,187 INFO [org.springframework.web.context.ContextLoader] - Root WebApplicationContext: initialization completed in 3391 ms
2009-07-23 12:06:39,703 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts-default.xml]
2009-07-23 12:06:40,218 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts-plugin.xml]
2009-07-23 12:06:40,265 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts.xml]
2009-07-23 12:06:40,640 INFO [org.apache.struts2.spring.StrutsSpringObjectFactory] - Initializing Struts-Spring integration...
2009-07-23 12:06:40,640 INFO [com.opensymphony.xwork2.spring.SpringObjectFactory] - Setting autowire strategy to name
2009-07-23 12:06:40,640 INFO [org.apache.struts2.spring.StrutsSpringObjectFactory] - ... initialized Struts-Spring integration successfully
处理:
2009-07-23 12:06:28,828 INFO [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]] -
2009-07-23 12:06:35,796 INFO [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/PurchaseDemo]]
对比下这两行,最后一点,一个是/,另一个是/PurchaseDemo;可能的推断:
1、你确实存在两个Spring的应用?
2、Spring的配置文件在不同位置有两份?
还是本来就是有继承关系的两个容器;
2009-07-23 12:06:28,828 INFO [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]] - Initializing Spring root WebApplicationContext
2009-07-23 12:06:28,828 INFO [org.springframework.web.context.ContextLoader] - Root WebApplicationContext: initialization started
2009-07-23 12:06:28,984 INFO [org.springframework.web.context.support.XmlWebApplicationContext] - Refreshing org.springframework.web.context.support.XmlWebApplicationContext@23d275: display name [Root WebApplicationContext]; startup date [Thu Jul 23 12:06:28 CST 2009]; root of context hierarchy
2009-07-23 12:06:29,250 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
2009-07-23 12:06:30,437 INFO [org.springframework.web.context.support.XmlWebApplicationContext] - Bean factory for application context [org.springframework.web.context.support.XmlWebApplicationContext@23d275]: org.springframework.beans.factory.support.DefaultListableBeanFactory@24ea85
2009-07-23 12:06:30,593 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@24ea85: defining beans [initdb]; root of factory hierarchy
2009-07-23 12:06:31,312 INFO [org.apache.torque.Torque] - TorqueInit Success
2009-07-23 12:06:31,421 INFO [org.springframework.web.context.ContextLoader] - Root WebApplicationContext: initialization completed in 2593 ms
2009-07-23 12:06:31,906 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts-default.xml]
2009-07-23 12:06:32,515 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts-plugin.xml]
2009-07-23 12:06:32,562 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts.xml]
2009-07-23 12:06:33,062 INFO [org.apache.struts2.spring.StrutsSpringObjectFactory] - Initializing Struts-Spring integration...
2009-07-23 12:06:33,062 INFO [com.opensymphony.xwork2.spring.SpringObjectFactory] - Setting autowire strategy to name
2009-07-23 12:06:33,062 INFO [org.apache.struts2.spring.StrutsSpringObjectFactory] - ... initialized Struts-Spring integration successfully
2009-07-23 12:06:35,796 INFO [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/PurchaseDemo]] - Initializing Spring root WebApplicationContext
2009-07-23 12:06:35,796 INFO [org.springframework.web.context.ContextLoader] - Root WebApplicationContext: initialization started
2009-07-23 12:06:35,968 INFO [org.springframework.web.context.support.XmlWebApplicationContext] - Refreshing org.springframework.web.context.support.XmlWebApplicationContext@ff0d4b: display name [Root WebApplicationContext]; startup date [Thu Jul 23 12:06:35 CST 2009]; root of context hierarchy
2009-07-23 12:06:36,234 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
2009-07-23 12:06:38,046 INFO [org.springframework.web.context.support.XmlWebApplicationContext] - Bean factory for application context [org.springframework.web.context.support.XmlWebApplicationContext@ff0d4b]: org.springframework.beans.factory.support.DefaultListableBeanFactory@c6b8b0
2009-07-23 12:06:38,203 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@c6b8b0: defining beans [initdb]; root of factory hierarchy
2009-07-23 12:06:38,968 INFO [org.apache.torque.Torque] - TorqueInit Success
2009-07-23 12:06:39,187 INFO [org.springframework.web.context.ContextLoader] - Root WebApplicationContext: initialization completed in 3391 ms
2009-07-23 12:06:39,703 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts-default.xml]
2009-07-23 12:06:40,218 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts-plugin.xml]
2009-07-23 12:06:40,265 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts.xml]
2009-07-23 12:06:40,640 INFO [org.apache.struts2.spring.StrutsSpringObjectFactory] - Initializing Struts-Spring integration...
2009-07-23 12:06:40,640 INFO [com.opensymphony.xwork2.spring.SpringObjectFactory] - Setting autowire strategy to name
2009-07-23 12:06:40,640 INFO [org.apache.struts2.spring.StrutsSpringObjectFactory] - ... initialized Struts-Spring integration successfully
处理:
2009-07-23 12:06:28,828 INFO [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]] -
2009-07-23 12:06:35,796 INFO [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/PurchaseDemo]]
对比下这两行,最后一点,一个是/,另一个是/PurchaseDemo;可能的推断:
1、你确实存在两个Spring的应用?
2、Spring的配置文件在不同位置有两份?
还是本来就是有继承关系的两个容器;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询