本身寫了個最簡單的springMVC項目練練手,沒有用maven,在WebContent中新建了lib文件夾,將jar包複製到這裏面,而後add to build path到項目裏。java
啓動Tomcat,報錯,啓動不起來。在網頁中運行localhost:8080發現Tomcat頁面是能夠打開的。web
報錯內容以下:spring
1 嚴重: A child container failed during start 2 java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/zhang]] 3 at java.util.concurrent.FutureTask.report(FutureTask.java:122) 4 at java.util.concurrent.FutureTask.get(FutureTask.java:188) 5 at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123) 6 at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:799) 7 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 8 at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) 9 at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) 10 at java.util.concurrent.FutureTask.run(FutureTask.java:262) 11 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 12 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 13 at java.lang.Thread.run(Thread.java:745) 14 Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/zhang]] 15 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) 16 ... 6 more 17 Caused by: java.lang.NoClassDefFoundError: org/springframework/web/context/WebApplicationContext 18 at java.lang.Class.getDeclaredFields0(Native Method) 19 at java.lang.Class.privateGetDeclaredFields(Class.java:2436) 20 at java.lang.Class.getDeclaredFields(Class.java:1806) 21 at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106) 22 at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:261) 23 at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:140) 24 at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:65) 25 at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:403) 26 at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:879) 27 at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:374) 28 at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) 29 at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) 30 at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5355) 31 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 32 ... 6 more 33 Caused by: java.lang.ClassNotFoundException: org.springframework.web.context.WebApplicationContext 34 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720) 35 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) 36 ... 20 more
網上百度你們都說是jar包缺乏。可是檢查spring所須要的jar包,都存在,以下圖。apache
而後就看lib文件是否是有問題,果真有問題。app
原來個人lib文件夾在WebContent下,將它放到WEB-INF目錄下,再從新將jar包add to build path裏,項目就能啓動了。maven
如今將這個問題分享出來,但願能幫到其餘的朋友。ui
可能我犯得這個錯誤很低級,別人不會犯這種錯誤吧。^_^spa