maven添加 xfire-all-1.2.6.jar 致使的spring配置文件異常

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項目中進行.
相關文章
相關標籤/搜索