Maven项目下update maven后Eclipse报错:java.lang.ClassNotFoundException: ContextLoaderListener

Maven web项目启动时报:
严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

问题背景

工程为maven工程,ContextLoaderListener类位于spring-web-3.2.4.RELEASE.jar包中。检查了maven的pom.xml,依赖引入正常。在工程Maven Dependencies视图中也能看到spring-web-3.2.4.RELEASE.jar包被正常引入进来了。

错误原因:

进入到tomcat的部署路径.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\下检查了一下,发现工程部署后在WEB-INF文件夹下没有生成lib目录,正常情况下,会生成lib目录并把工程的所有依赖jar包都部署到该目录下。

Eclipse和Myeclipse解决方案:

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

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

2.点击Next,选择Maven Dependencies(选择文件夹)

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

操作完成之后,重新进行部署项目,发现.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\目录下,发现工程WEB-INF目录下自动生成了lib目录,项目不再报错,问题解决。

猜你喜欢

转载自blog.csdn.net/qq_21875331/article/details/80797728
今日推荐