100%解决java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet异常

时间:2024-03-30 22:36:16
  • 针对Java IDEA
  • 在搭建springmvc框架时,Tomcat也配置好了,但启动时报错。
  • java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1365) org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373) org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590) org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) 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)
    该问题是项目的WEB_INF目录下没有lib文件夹导致。查找各种资料,现记录解决方法。
    点击左上角File
    选择Project Structure
    点击Artifacts
    100%解决java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet异常
    100%解决java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet异常
    重新启动Tomacat即可。