IDE:Eclipse-mars 架构:springMVC + maven项目 以下为网上转载,原地址(http://blog.csdn.net/itlion...
(ContextLoader.java:383) at org.springframework.web.context.ContextLoader.initWebApplicationContext...(ContextLoader.java:283) at org.springframework.web.context.ContextLoaderListener.contextInitialized...(ContextLoader.java:383) at org.springframework.web.context.ContextLoader.initWebApplicationContext...(ContextLoader.java:549) at org.springframework.web.context.ContextLoaderListener.contextDestroyed...(ContextLoader.java:549) at org.springframework.web.context.ContextLoaderListener.contextDestroyed
extends ContextLoader implements ServletContextListener { private ContextLoader contextLoader;...= createContextLoader(); if (this.contextLoader == null) { this.contextLoader = this;...(ServletContextEvent event) { if (this.contextLoader !...= null) { this.contextLoader.closeWebApplicationContext(event.getServletContext()); }...; } Log logger = LogFactory.getLog(ContextLoader.class); servletContext.log("Initializing
implements ServletContextListener { 2 3 private ContextLoader contextLoader; 4 5 6...See {@link ContextLoader} superclass documentation for details on 10 * default values for each....= createContextLoader(); 69 if (this.contextLoader == null) { 70 this.contextLoader...()); 73 } 74 75 /** 76 * Create the ContextLoader to use....public ContextLoader getContextLoader() { 94 return this.contextLoader; 95 } 96
一 问题描述: maven项目,由于jar冲突,导致项目启动时报错: 09:58:25,070 ERROR [org.springframework.web.context.ContextLoader...(ContextLoader.java:348) at org.springframework.web.context.ContextLoader.initWebApplicationContext(...ContextLoader.java:281) at org.springframework.web.context.ContextLoaderListener.contextInitialized(...(ContextLoader.java:348) at org.springframework.web.context.ContextLoader.initWebApplicationContext(...ContextLoader.java:281) at org.springframework.web.context.ContextLoaderListener.contextInitialized(
获取WebApplicationContext的实现类 在org.springframework.web.context.ContextLoader中有一个静态属性, static {...try { ClassPathResource resource = new ClassPathResource(DEFAULT_STRATEGIES_PATH, ContextLoader.class...} catch (IOException ex) { throw new IllegalStateException("Could not load 'ContextLoader.properties...': " + ex.getMessage()); } } 默认的DEFAULT_STRATEGIES_PATH=ContextLoader.properties,路径在ContextLoader...ContextLoader.properties的内容为: # Default WebApplicationContext implementation class for ContextLoader.
-->ContextLoader.createWebApplicationContext-->ContextLoader.determineContextClass-->ContextLoader.determineContextClass...defaultStrategies 的实现如下: /** * Name of the class path resource (relative to the ContextLoader class)...* that defines ContextLoader's default strategy names. */ private static final String DEFAULT_STRATEGIES_PATH...= "ContextLoader.properties"; private static final Properties defaultStrategies; static { // 读取文件..., ContextLoader.class); defaultStrategies = PropertiesLoaderUtils.loadProperties(resource);
ContextLoaderListener源码 可以发现 ContextLoaderListener 继承自 ContextLoader,并且还实现了 ServletContextListener...web.xml加载初始化后获取的 ServletContext 传入initWebApplicationContext方法中进行IoC容器的初始化 initWebApplicationContext 方法从 ContextLoader...继承而来,进入ContextLoader 源码中看看 ?...ContextLoader类中的静态代码块 建一个 ClassPathResource 对象,同时把值为 ContextLoader.properties...易知ContextLoader.properties 文件与 ContextLoader 类是在同一个目录下的;ContextLoader.properties 文件内容如下 org.springframework.web.context.WebApplicationContext
initWebApplicationContext(event.getServletContext()); } 继续进入initWebApplicationContext方法,这个方法在其父类ContextLoader...already a root application context present - " + "check whether you have multiple ContextLoader...; } Log logger = LogFactory.getLog(ContextLoader.class); servletContext.log("...private static final String DEFAULT_STRATEGIES_PATH = "ContextLoader.properties"; private static...': " + ex.getMessage()); } } 也就是说在ContextLoader.java的路径下,有一个ContextLoader.properties文件,查找并打开这个文件
contextInitialized 方法代码如下 public void contextInitialized(ServletContextEvent event) { //因为本身就是ContextLoader...的子类,这里可以直接使用ContextLoader来初始化IoC容器 this.contextLoader = createContextLoader(); if...(this.contextLoader == null) { this.contextLoader = this } this.contextLoader.initWebApplicationContext
改造完成之后在本地可以正常启动正常访问,但是上到线上服务器之后会出现如下错误信息 2022-01-07 10:43:43,779 ERROR [org.springframework.web.context.ContextLoader...(ContextLoader.java:385) at org.springframework.web.context.ContextLoader.initWebApplicationContext...(ContextLoader.java:284) at org.springframework.web.context.ContextLoaderListener.contextInitialized...(ContextLoader.java:385) at org.springframework.web.context.ContextLoader.initWebApplicationContext...(ContextLoader.java:284) at org.springframework.web.context.ContextLoaderListener.contextInitialized
ContextLoaderListener继承自ContextLoader,实现的是ServletContextListener接口。...public class ContextLoaderListener extends ContextLoader implements ServletContextListener {...来实现的,ContextLoader来完成实际的WebApplicationContext, 也就是Ioc容器的初始化工作。...它通过传递给它所接收到的servlet上下文(从事件参数获取event.getServletContext())来调用ContextLoader的initWebApplicationContext方法。...这个方法干了两件事情: 通过ContextLoader中的closeWebApplicationContext(),它关闭应用程序上下文。
(ContextLoader.java:401) at org.springframework.web.context.ContextLoader.initWebApplicationContext(...ContextLoader.java:292) at org.springframework.web.context.ContextLoaderListener.contextInitialized(...(ContextLoader.java:401) at org.springframework.web.context.ContextLoader.initWebApplicationContext(...(ContextLoader.java:401) at org.springframework.web.context.ContextLoader.initWebApplicationContext(...(ContextLoader.java:401) at org.springframework.web.context.ContextLoader.initWebApplicationContext(
private ContextLoader contextLoader; public ContextLoaderListener() { } public ContextLoaderListener...= createContextLoader(); if (this.contextLoader == null) { this.contextLoader = this...ContextLoader getContextLoader() { return this.contextLoader; } public void contextDestroyed...(ServletContextEvent event) { if (this.contextLoader !...在ContextLoaderListener中关联了ContextLoader这个类,整个加载配置过程由ContextLoader来完成。
ContextLoader contextLoader; public ContextLoaderListener() { } public ContextLoaderListener(WebApplicationContext...= createContextLoader(); if (this.contextLoader == null) { this.contextLoader = this; } this.contextLoader.initWebApplicationContext...null; } @Deprecated public ContextLoader getContextLoader() { return this.contextLoader; }...public void contextDestroyed(ServletContextEvent event) { if (this.contextLoader !...在ContextLoaderListener中关联了ContextLoader这个类,整个加载配置过程由ContextLoader来完成。
(ContextLoader.java:410) at org.springframework.web.context.ContextLoader.initWebApplicationContext(...ContextLoader.java:306) at org.springframework.web.context.ContextLoaderListener.contextInitialized(...ContextLoaderListener#contextInitialized方法 /** public void contextInitialized(ServletContextEvent event) { this.contextLoader...= createContextLoader(); if (this.contextLoader == null) { this.contextLoader = this; } this.contextLoader.initWebApplicationContext...(event.getServletContext()); } 发现最后调用initWebApplicationContext初始化应用上下文,下一步到ContextLoader#initWebApplicationContext
(ContextLoader.java:389) at org.springframework.web.context.ContextLoader.initWebApplicationContext(...(ContextLoader.java:389) at org.springframework.web.context.ContextLoader.initWebApplicationContext(...(ContextLoader.java:389) at org.springframework.web.context.ContextLoader.initWebApplicationContext(...(ContextLoader.java:389) at org.springframework.web.context.ContextLoader.initWebApplicationContext(...(ContextLoader.java:389) at org.springframework.web.context.ContextLoader.initWebApplicationContext(
(ContextLoader.java:244) at org.springframework.web.context.ContextLoader.initWebApplicationContext...(ContextLoader.java:244) at org.springframework.web.context.ContextLoader.initWebApplicationContext...(ContextLoader.java:244) at org.springframework.web.context.ContextLoader.initWebApplicationContext...(ContextLoader.java:244) at org.springframework.web.context.ContextLoader.initWebApplicationContext...(ContextLoader.java:244) at org.springframework.web.context.ContextLoader.initWebApplicationContext
ff0000;”> implements ServletContextListener { private ContextLoader...contextLoader; /** * Initialize the root web application context. */ public...void contextInitialized(ServletContextEvent event) { this.contextLoader...= createContextLoader(); this.contextLoader....because there is already a root application context present – “ + “check whether you have multiple ContextLoader
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext...(ContextLoader.java:403) at org.springframework.web.context.ContextLoader.initWebApplicationContext(...ContextLoader.java:306) at org.springframework.web.context.ContextLoaderListener.contextInitialized(
领取专属 10元无门槛券
手把手带您无忧上云