概述
收集平时遇到的spring启动异常
org.springframework.web.context.ContextLoaderListener
在 web.xml中加入 以下配置后,启动失败
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
报错如下
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionorg.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefresha
[2019-05-16 10:02:26,943] Artifact springdemo1:war exploded: Error during artifact deployment. See server log for details.
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:141)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:330)
... 57 more
IOException 还是没有读到 applicationContext.xml,手动copy到out 的WEB-INF下,运行OK
删除idea创建mvc项目中的lib文件夹
通过tomcat 启动springmvc,TomcatLocalLog 中报错 ClassNotFound
根本原因还是tomcat没有加载到jar
1、将mvc核心包copy到tomcat 目录 lib文件夹下,运行OK
2、在项目根目录下创建lib文件夹,copy核心包,前端页面可以访问,但是TomcatLocalLog 已经报错 java.lang.ClassNotFoundException: org.springframework.context.ApplicationContextAware
改为都放在tomcat/lib下,一切正常
加入listener配置后,报错
16-May-2019 11:09:56.731 严重 [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.listenerStart Error configuring application listener of class [org.springframework.web.context.ContextLoaderListener]
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
out/…/lib下还未引入
Artifacts 下 执行putinto操作
添加到了这里