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包。




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章