spring mvc

如题,在eclipse启动的时报java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

开发环境:eclipse、maven

网上分析的原因有以下几种:

1、缺少spring jar包

2、web.xml初始化监听器配置错误(以下配置可正常运行,可供参考):

1 <!-- 初始化配置文件 -->
2     <listener>
3         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
4     </listener>
5     <context-param>
6         <param-name>contextConfigLocation</param-name>
7         <param-value>classpath*:/applicationContext/application_spring_mvc.xml</param-value>
8     </context-param>

3、spring的包起冲突

解决方案(针对包冲突):

方案一:把部署的tomcat删除,清理一下,然后重建在运行,意思就是把之前部署的jar包清理干净在重新运行。

方案二:项目右击 - "Properties" - "Deployment Assembly" ,点击"ADD",选择"Java Build Path Entries"-"Maven Dependencies" ,保存即可

最终以第二种方案解决掉此问题。

原文地址:https://www.cnblogs.com/curen/p/5757315.html