Spring-mvc的怪事之java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet

javax.servlet.ServletException: Error instantiating servlet class org.springframework.web.servlet.DispatcherServlet
	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
	org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:1025)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
	org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1137)
	org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
	org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:317)
	java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	java.lang.Thread.run(Thread.java:748)

原因分析:

由于maven没有将lib文件夹打包到jar或war中,经过排查,确实是缺少lib依赖所引起的报错!

解决方式:

***IDEA -- ***
打开projectstructure
  artifacts -》war或者web exploaded -》available elements下的lib右键菜单 -》put into outroot
***eclipse -- ***
在项目上右键properties(应该是最后一项),打开如下界面

  Add -》 Java Build Path Entries -》 Next -》 Maven Dependencies -》 Finish -》 Ok,配置完后如下图:
Spring-mvc的怪事之java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet_第1张图片
Spring-mvc的怪事之java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet_第2张图片

你可能感兴趣的:(Spring-mvc的怪事之java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet)