最近開發的一個項目一直存放在移動硬盤上,結果前天由於查了多個設備,盤符就變了,Eclipse也就找不到了項目。把項目拷回本地磁盤後,重新打開。直接Run On Server,提示ClassNotFoundException,找不到Spring ApplicationContext。進到%ECLIPSE_WORKSPACE%\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\myapp\下查看,發現WEB-INF下沒有lib目錄。檢查project的build path沒有問題。最後google一下,發現了StackOverflow上一個回答:
http://stackoverflow.com/questions/6083501/maven-dependencies-not-visible-in-web-inf-lib
我是按照第三種方法解決的:
右鍵打開項目屬性-->找到“Deployment Assembly”-->點擊“Add”-->Java Build Path Entries-->"Maven Dependecies",保存後,重新Run On Server啓動運行。