1. 程式人生 > >maven web-app啟動報錯:ClassNotFoundException: ContextLoaderListener

maven web-app啟動報錯:ClassNotFoundException: ContextLoaderListener

今天開啟myeclispe,啟動昨天寫了一半的專案,tomcat啟動報錯,如標題。 明明昨天好好的,啥也沒改就突然出現這個錯誤,很是無語,eclipse的bug?

錯誤說的很清楚:spring下的ContextLoaderListener.class找不到。

看了一眼maven依賴下的spring-web-release-xxx.jar發現這個class是存在的,說明不是jar包的問題。那麼就可能是釋出專案的時候這個jar沒有打包進tomcat。

解決方法如下

  1. 右鍵–properties–Deployment–Deployment Assembly 這裡寫圖片描述
  2. 點選 Add -> Java Build Path Entries -> Next
  3. 選擇 Maven Dependencies -> Finish -> Apply -> OK 這裡寫圖片描述
  4. Clean project and server. 重啟server 發現可以運行了。