1. 程式人生 > >Spring MVC 啟動報錯

Spring MVC 啟動報錯

右鍵 pro 錯誤 prop 工程項目 con ont server otf

Tomcat 啟動Spring MVC工程報如下錯誤

java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1305)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1139)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:518)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:499)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4733)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5251)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

是因為沒有將Maven 下的JAR 包添加至工程的依賴中

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

Spring MVC 啟動報錯