当服务器启动 Spring 为什么会加载两次

 我来答
平行七边形
2014-12-15 · TA获得超过110个赞
知道小有建树答主
回答量:77
采纳率:0%
帮助的人:78.3万
展开全部
spring的加载过程就是加载各个bean,一个应用当然不止一个bean,不存在你说的加载两次,如果一个bean被加载两次,说明配置文件写的有问题。
百度网友63827ba
2015-09-09 · TA获得超过460个赞
知道小有建树答主
回答量:927
采纳率:55%
帮助的人:322万
展开全部
看看生命周期代码对不对
还有webxml
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
huandao13
2015-07-18 · TA获得超过158个赞
知道小有建树答主
回答量:184
采纳率:0%
帮助的人:152万
展开全部
案例:
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的配置文件在不同位置有两份?
还是本来就是有继承关系的两个容器;
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式