spring加载顺序

 

加载顺序,借网上的图:



 官方文档描述:

 

  When a web application is deployed into a container, the following steps must be performed, in this order, before the web application begins processing client requests.

 

1、Instantiate an instance of each event listener identified by a <listener> element in the deployment descriptor.

2、For instantiated listener instances that implement ServletContextListener, call the contextInitialized() method.

3、Instantiate an instance of each filter identified by a <filter> element in the deployment descriptor and call each filter instance's init() method.

4、Instantiate an instance of each servlet identified by a <servlet> element that includes a <load-on-startup> element in the order defined by the load-on-startup element values, and call each servlet instance's init() method.

所以,加载的先后顺序,可能会出问题,如果在spring.xml配置中把Controller(属于DispatcherServlet内容)也加载了,就可能出现在spring-web.xml加载中,发现Controller已经加载,有些内容不再加载了。所以需要使用<context:component-scan....>等

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值