1. 程式人生 > >SpringMVC常見問題java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

SpringMVC常見問題java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

在用Eclipse和Maven構建SpringMVC專案中,

Maven Dependencies中已經有了spring-webmvc的jar包,

並且在其中也有org.springframework.web.context.ContextLoaderListener類,但是執行的時候出現java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener問題,

原因不知道,

解決辦法參考http://stackoverflow.com/questions/21237339/java-lang-classnotfoundexception-org-springframework-web-context-contextloaderl

和http://commonexceptions.blogspot.jp/2014/01/java.html。

解決步驟:

1.Open project properties;

2.Select "Deployment Assembly"

3.Click "Add..." button on the right navigation

4.Select "Java Build Path Entries" from menu of Directive Type and then click "Next"

5.Select "Maven Dependencies" from Java Build Path Entries menu and then click "Finish"

猜測原因可能是因為沒有把Maven Dependencies新增到依賴路徑中。

然後在刪除Server中的伺服器,最後CLean Project和Build Project,可能需要重啟Eclipse。