使用Idea新建了一個springmvc的項目,可是啓動的時候報這個異常。 Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListenerjava
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>*.form</url-pattern> </servlet-mapping> </web-app>
百度後發現其實ecplise中也有過這種問題,jar明明在卻就是找不到,最後的解決方案發現tomcat的應用下面沒有lib這個文件夾,致使jar沒法放進去,從而出現的這個問題。web
服務器報錯信息:spring
23-Jul-2018 10:27:28.858 嚴重 [RMI TCP Connection(3)-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
按照上面ecplise發生的錯誤,檢查idea的配置(推測是由於jar沒有放入web-inf下面)apache
由於項目在編寫時沒有出現問題,應該是在打包發佈的時候出現了問題tomcat
以下圖能夠看到WEB-INF文件下並無lib目錄,而在右邊顯示可用的元素服務器
而後咱們就能夠在web-inf小面看到咱們添加的jar包mvc
那麼接下來再啓動咱們的Tomcatapp
問題完美解決ide