一、概述
中午不睡觉,来记录点东西。
某历史遗留项目,因为这几天的log4j漏洞问题要升级,但是由于种种原因,当时上线部署的包跟现在的代码已经对应不上了,现在已掌握的代码已经更新了很多内容了,当时部署在哪个版本的Tomcat里也不清楚了,只能挨个Tomcat找,最后定位在Tomcat7和Tomcat8两个版本的Tomcat中。
二、问题与解决过程
代码打完包之后,首先上传到了Tomcat8中,启动就报错了
Invalid content was found starting with element 'mvc:exclude-mapping'
原因是:mvc:exclude-mapping 标签不被spring-mvc-3.0.xsd支持,在配置文件中将其改为spring-mvc-3.2.xsd。
改完之后该问题解决。
接着又遇到如下报错
Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping': Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: org.springframework.web.servlet.handler.AbstractHandlerMapping.obtainApplicationContext()Lorg/springframework/context/ApplicationContext;
咦,这个问题有点眼熟,jar包冲突,大伙也都是这么说的,无奈,待我用maven helper将看似冲突的依赖都排除之后还是有这个问题;转念一想,既然之后服务器上有Tomcat7,难不成是在7上运行的,于是挪过去试了试,唉,解决了。
三、总结
1、spring-mvc-3.0.xsd版本问题;
2、遇到如下这类问题,除了考虑依赖冲突的问题,还要考虑Tomcat的版本(如果你打的包也是war的话)。
Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping': Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: org.springframework.web.servlet.handler.AbstractHandlerMapping.obtainApplicationContext()Lorg/springframework/context/ApplicationContext;