maven 工程啟動找不到 Spring ContextLoaderListener 的解決辦法


   用maven 工程搭建項目,在搭建好之后,運行時卻拋出了這樣的錯誤:  Error configuring application listener of class org.springframework.web.context.ContextLoaderListener  
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener, 這說明根本沒有找到我們在 web.xml 里面配置的 listener, 但maven 的pom.xml  里面已經配置相應的包,而且可以在java 工程的maven dependency jar 包里面找到, 這說明maven是沒有問題的,在網上搜索了很多答案,最多的就是類似這個文章: http://www.cnblogs.com/zhouyalei/archive/2011/11/30/2268606.html 基本都是這樣去解決,但是貌似對我來說不行,而且比較麻煩,需要修改 .project , .classpath 等文件。其實有更簡單的辦法.
在eclipse 里面, 參考如下配置:

1. 右鍵單擊工程項目 ->點擊 properties
2. 選擇 Deployment Assembly
3. 點擊 Add -> Java Build Path Entries -> Next
4. 選擇 Maven Dependencies -> Finish -> Apply -> OK
5. Clean project and server. 重啟server

這樣就能解決maven  下找不到 spring listener 的問題。一個最明顯的變化是你的web 工程里面明顯多了一個jar包。

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM