Maven项目报错:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

Maven项目的启动出现了下面的错误信息:

严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1856)
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1705)
	at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:506)
	at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:488)
	at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:115)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4993)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5591)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

三月 27, 2019 10:18:55 上午 org.apache.catalina.core.StandardContext listenerStart
严重: Error configuring application listener of class org.springframework.web.util.IntrospectorCleanupListener
java.lang.ClassNotFoundException: org.springframework.web.util.IntrospectorCleanupListener
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1856)
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1705)
	at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:506)
	at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:488)

错误原因:

进入到tomcat的部署路径下,发现工程部署后在WEB-INF文件夹下没有生成lib目录,正常情况下,会生成lib目录并把工程的所有依赖jar包都部署到该目录下。

 

解决方法:

1.右键点击项目--选择Properties

选择Deployment Assembly,在右边点击Add按钮,在弹出的窗口中选择Java Build Path Entries

Maven项目报错:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener_第1张图片

Maven项目报错:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener_第2张图片

2.点击Next,选择Maven Dependencies

Maven项目报错:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener_第3张图片

3.点击Finish,然后可以看到已经把Maven Dependencies添加到Web应用结构中了

Maven项目报错:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener_第4张图片

操作完后,重新部署工程,不再报错了。然后我们再到tomcat目录下,发现工程WEB-INF目录下自动生成了lib目录,并且所有的依赖jar包也都已经部署进来。问题因此解决。 

你可能感兴趣的:(Maven,配置,错误解决)