添加 xfire-all-1.2.6.jar 导致的spring配置文件异常

来源:互联网 发布:mastercam侧铣头编程 编辑:程序博客网 时间:2024/06/10 04:38

添加 xfire-all-1.2.6.jar 导致的spring配置文件错误

  1. 环境
    maven
    spring-3.2.3
    xfire-1.2.6

  2. 问题描述
    在工程中的 pom.xml 中添加 xfire

<dependency>    <groupId>org.codehaus.xfire</groupId>    <artifactId>xfire-all</artifactId>    <version>1.2.6</version></dependency>

只是添加了这个jar包,其他配置文件都没动,启动tomcat,报了如下的错误:
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包:

spring-1.2.6.jar

工程中的 spring 用的版本是 3.2.3 的,而这个多出来的 spring 版本是 1.2.6 的,造成了 jar 包冲突。
用压缩软件打开 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 中,将这个依赖关系去掉即可— 加上

<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>
0 0
原创粉丝点击