spring启动
spring的启动和关闭是通过在web.xml中注册启动监听器org.springframework.web.context.ContextLoaderListener来实现的,该类实现了接口javax.servlet.ServletContextListener。伴随web容器的启动和关闭,管理Spring的根org.springframework.web.context.WebApplicationContext。
该类本身并没有实现太多的代码,只是一个到org.springframework.web.context.ContextLoader和org.springframework.web.context.ContextCleanupListener的简单代理。
如果在web.xml中配置了org.springframework.web.util.Log4jConfigListener,则该监听器必须配置在它的后面。在spring3.1之后,如果在Servlet 3.0以上环境,ContextLoaderListener支持通过ContextLoaderListener(WebApplicationContext)构造器,以编码的方式来注入web应用的根上下文,而不用再在web.xml中进行配置。
当ContextLoaderListener在进行实例化的时候,会读取web.xml中配置的两个context-param参数:“contextClass“、“contextConfigLocation”。
ContextLoaderListener实例化之后,将会被注册到ServletContext的WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE属性上。
在Servlet3.0+环境中,使用ContextLoaderListener(WebApplicationContext)构造器,以编码的方式(非web.xml配置方式)通过javax.servlet.ServletContext.addListener接口注册该实例,如果context实例同时满足:实现ConfigurableWebApplicationContext接口、尚未刷新,将会产生以下操作:
- 如果context还没有id,将通过setId接口赋予id;
- ServletContext、ServletConfig将被代理到context;
- customizeContext方法将被调用;
- 所有通过contextInitializerClasses初始化参数配置的 ApplicationContextInitializer接口实现都将被应用;
- 调用refresh接口;
如果context实例已经刷新或者没有实现ConfigurableWebApplicationContext接口,以上操作不会自动发生,需要用户根据自己的需用自行调用。
- Spring + Tomcat 启动报错java.lang.ClassNotFoundException: org.apache.commons.pool.impl.GenericObjectPool
- 启动报错:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- Spring启动时报异常:No String constructor found on type [java.lang.reflect.Method]
- maven 工程启动找不到 Spring ContextLoaderListener 的解决办法
- Spring quartz 任务调度器 启动加载,定时加载
- Spring 集成 MyBatis: 自动注入映射器导致项目启动报错
- 学习spring-boot第一节demo运行与web启动
- Maven项目Eclipse启动时报错: java.lang.ClassNotFoundException: org.springframework.web.util.IntrospectorCleanupListener
- web服务启动spring自己主动运行ApplicationListener的使用方法
- Spring整合struts2中Tomcat启动可能出错原因之一
- 应用完全启动后, Spring执行自定义初始化
- spring启动component-scan类扫描加载过程---源码分析
- SpringBoot启动原理
- 启动报Duplicate fragment name: spring_web for jar
- spring容器启动,初始化某个方法(init)
- Springboot 启动CallCenterApplication报错
- Struts2,action中用spring注入,启动服务时注入成功,action运行时对象又变成null了
- 为什么spring cloud服务启动之后回到命令行会自动挂掉
- 系统启动PropertyPlaceholderConfigurer加载配置到spring容器中
- spring-boot启动配置及cmd安装jar包方法