maven添加 xfire-all-1.2.6.jar 致使的spring配置文件错误
spring
1. 环境tomcat
mavenapp
spring-3.2.3maven
xfire-1.2.6ui
2. 问题描述spa
在工程中的 pom.xml 中添加 xfirecode
<dependency> <groupId>org.codehaus.xfire</groupId> <artifactId>xfire-all</artifactId> <version>1.2.6</version> </dependency>
只是添加了这个jar包,其余配置文件都没动,启动tomcat,报了以下的错误:xml
Line 8 in XML document from class path resource [applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null".
查看工程的 Java Build Path 中的 Maven Dependencies 发现多了个 spring 的jar包:ci
工程中的 spring 用的版本是 3.2.3 的,而这个多出来的 spring 版本是 1.2.6 的,形成了 jar 包冲突。element
用压缩软件打开 xfire-all-1.2.6.jar ,在其目录 META-INF\maven\org.codehaus.xfire\xfire-jms 的 pom.xml 中发现:
<dependency> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> </dependency>
只须要将这个 spring-1.2.6.jar 从工程中删除便可。
可是发现,在 Maven Dependencies 中根本删除不了。
了解到,这个 spring-1.2.6.jar 是依赖于 xfire-all-1.2.6 的,故而,在 工程的 pom.xml 中,将这个依赖关系去掉便可--- 加上 <exclusions>
<dependency> <groupId>org.codehaus.xfire</groupId> <artifactId>xfire-all</artifactId> <version>1.2.6</version> <exclusions> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> <version>1.2.6</version> </exclusion> </exclusions> </dependency> 转者注:修改pom.xml数据要在新建maven项目或者从SVN检出没有convert to maven project项目中进行.