Error configuring application listener of class org.springframework.web.context.ContextLoaderListner

新导入一个Dynamic web项目,发现没有关于servlet的jar包,此时我选择了直接使用tomcat的api来代替该jar包

即右击项目选择属性,点击Tagerted run…
在这里插入图片描述

此时项目不再报错,但当部署到tomcat发布时,出现了

Error configuring application listener of class org.springframework.web.context.ContextLoaderListner

这时有两个思考方向

1.jar包没有正确导入
排查后发现,jar包在项目中导入完全,该可能排除
在这里插入图片描述
2.jar包冲突问题
这时想到了可能是tomcat包里的某些jar包lib文件里的jar包冲突了
于是决定使用servlet-apijsp-api代替
把这两个jar包放到lib文件夹里并右键Build path–>add to Build path
在这里插入图片描述
这时候再启动tomcat就不会报错

总结:

当web.xml里是使用ContextLoaderListner来加载配置文件,即

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/classes/spring/applicationContext-*.xml</param-value>
  </context-param>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

并且没有servlet的api时,最好外部导入servlet的jar包,而不要直接使用tomcat的api来代替该jar包

猜你喜欢

转载自blog.csdn.net/weixin_44538032/article/details/89937994
今日推荐