出错一:
Eclipse+maven+springMVC环境搭建时 在jetty下没有问题(采用的方式是在控制台执行 mvn jetty:run指令方式),但是在 Eclipse+Tomcat+maven+springMVC
严重: Servlet [mvc-dispatcher] in web application [/spring-mvc-learning] threw load() exception
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServletat org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1892)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1735)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:504)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:486)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:113)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1133)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1072)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5368)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5660)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:679)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1966)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
这种问题是由于 deployment assembly maven依赖没有添加。
解决方法:右击工程,选择properties,左边拉到最上面选择Deployment Assembly
点击Add按钮,选择Java Build Path Entries,点击Next
选择 Java Build Path Entries,点Next
选择Maven Dependencies,点击Finish后Apply
这时候重启下tomcat就完美运行了。
出错二:
报错 java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.Config
解决方法:在pom.xml 中加
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>jstl</artifactId>
- <version>1.2</version>
- <scope>runtime</scope>
- </dependency>