spring配置CentextLoaderListener监听器后启动tomcat报错:ClassNotFoundException: org.springframework.web.context.ContextLoaderListene

错误描述:由maven管理的spring框架的web项目,想要使用spring提供的工具类自动创建应用上下文对象ApplicationContext并存储到SerlvetContext域中,为此在pom.xml中引入spring-web依赖,并在web.xml配置ContextLoaderListener监听器和全局变量定义contextConfigLocation。代码没有报错,但在启动后出现java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener错误。

错误原因:有时在pom.xml引入jar包依赖后没有将该jar包设置成打包包含,导致web项目打包后没有该包,自然报notfound错误。检查自己项目是否包含自己需要的包:

解决办法:在project structure  1. 选择Artifacts  2. 选中自己的模块 3. 右侧的Available Elements中选中对应的模块,右键Put into Output Root。重启tomcat即可。

posted @ 2020-08-01 16:56  风和雨滴  阅读(1031)  评论(0编辑  收藏  举报