2015-03-30 241 views
3

在我的項目中,我依賴幾個外部庫,這些庫取決於xml-apis的各種版本。如果我使用maven-enforcer-pluginto fail if there are version conflicts我的構建失敗。將傳遞依賴行爲與xml-apis混淆

在我開始,我的打印應用程序運行的類路徑給出xml-apis:xml-apis:1.4.01

當我使maven-enforcer-plugin我得到這個,預計

Dependency convergence error for xml-apis:xml-apis:1.3.04 paths to dependency are: 

+-org.bbraile:bbraile:1.0-SNAPSHOT 
    +-org.bbraile:utd:1.0-SNAPSHOT 
    +-xalan:xalan:2.7.2 
     +-xalan:serializer:2.7.2 
     +-xml-apis:xml-apis:1.3.04 
and 
+-org.bbraile:bbraile:1.0-SNAPSHOT 
    +-org.bbraile:utd:1.0-SNAPSHOT 
    +-xml-apis:xml-apis:1.4.01 
and 
+-org.bbraile:bbraile:1.0-SNAPSHOT 
    +-org.bbraile:utd:1.0-SNAPSHOT 
    +-xerces:xercesImpl:2.11.0 
     +-xml-apis:xml-apis:1.4.01 
and 
+-org.bbraile:bbraile:1.0-SNAPSHOT 
    +-com.io7m.xom:xom:1.2.10 
    +-xml-apis:xml-apis:1.3.03 
and 
+-org.bbraile:bbraile:1.0-SNAPSHOT 
    +-org.apache.xmlgraphics:batik-transcoder:1.7 
    +-org.apache.xmlgraphics:batik-bridge:1.7 
     +-org.apache.xmlgraphics:batik-anim:1.7 
     +-xml-apis:xml-apis:1.3.04 
and 
+-org.bbraile:bbraile:1.0-SNAPSHOT 
    +-org.apache.xmlgraphics:batik-transcoder:1.7 
    +-org.apache.xmlgraphics:batik-bridge:1.7 
     +-org.apache.xmlgraphics:batik-css:1.7 
     +-xml-apis:xml-apis:1.3.04 
and 
+-org.bbraile:bbraile:1.0-SNAPSHOT 
    +-org.apache.xmlgraphics:batik-transcoder:1.7 
    +-org.apache.xmlgraphics:batik-bridge:1.7 
     +-org.apache.xmlgraphics:batik-ext:1.7 
     +-xml-apis:xml-apis:1.3.04 
and 
+-org.bbraile:bbraile:1.0-SNAPSHOT 
    +-org.apache.xmlgraphics:batik-transcoder:1.7 
    +-org.apache.xmlgraphics:batik-bridge:1.7 
     +-xml-apis:xml-apis:1.3.04 
and 
+-org.bbraile:bbraile:1.0-SNAPSHOT 
    +-org.apache.xmlgraphics:batik-transcoder:1.7 
    +-org.apache.xmlgraphics:batik-dom:1.7 
     +-xml-apis:xml-apis:1.3.04 
and 
+-org.bbraile:bbraile:1.0-SNAPSHOT 
    +-org.apache.xmlgraphics:batik-transcoder:1.7 
    +-org.apache.xmlgraphics:batik-gvt:1.7 
     +-xml-apis:xml-apis:1.3.04 
and 
+-org.bbraile:bbraile:1.0-SNAPSHOT 
    +-org.apache.xmlgraphics:batik-transcoder:1.7 
    +-org.apache.xmlgraphics:batik-svg-dom:1.7 
     +-xml-apis:xml-apis:1.3.04 
and 
+-org.bbraile:bbraile:1.0-SNAPSHOT 
    +-org.apache.xmlgraphics:batik-transcoder:1.7 
    +-org.apache.xmlgraphics:batik-svggen:1.7 
     +-xml-apis:xml-apis:1.3.04 
and 
+-org.bbraile:bbraile:1.0-SNAPSHOT 
    +-org.apache.xmlgraphics:batik-transcoder:1.7 
    +-xml-apis:xml-apis:1.3.04 

要解決此基礎上我讀過我應該將此添加到我的POM中

<dependencyManagement> 
    <dependencies> 
     <dependency> 
      <groupId>xml-apis</groupId> 
      <artifactId>xml-apis</artifactId> 
      <version>2.0.2</version> 
     </dependency> 
    </dependencies> 
</dependencyManagement> 

然後重新運行我的程序。它通過maven-enforcer-plugin檢查,但我的班級路徑現在說我正在運行xml-apis:xml-apis:1.0.b2。版本號是如何變老的?爲什麼我的版本被忽略?

添加這對我的POM,有或沒有<version>標籤沒有影響

<dependencies> 
    <dependency> 
     <groupId>xml-apis</groupId> 
     <artifactId>xml-apis</artifactId> 
     <version>2.0.2</version> 
    </dependency> 
</dependencies> 

諮詢dependency:tree -Dverbose=true -Dincludes=xml-apis列出了,這意味着2.0.2

org.bbraile:bbraile:jar:1.0-SNAPSHOT 
+- org.bbraile:utd:jar:1.0-SNAPSHOT:compile 
| +- xalan:xalan:jar:2.7.2:compile 
| | \- xalan:serializer:jar:2.7.2:compile 
| |  \- (xml-apis:xml-apis:jar:2.0.2:compile - version managed from 1.0.b2; omitted for duplicate) 
| +- (xml-apis:xml-apis:jar:2.0.2:compile - version managed from 1.0.b2; omitted for conflict with 1.0.b2) 
| \- xerces:xercesImpl:jar:2.11.0:compile 
|  \- (xml-apis:xml-apis:jar:2.0.2:compile - version managed from 1.0.b2; omitted for duplicate) 
+- com.io7m.xom:xom:jar:1.2.10:compile 
| \- (xml-apis:xml-apis:jar:2.0.2:compile - version managed from 1.0.b2; omitted for duplicate) 
+- org.apache.xmlgraphics:batik-transcoder:jar:1.7:compile 
| +- org.apache.xmlgraphics:batik-bridge:jar:1.7:compile 
| | +- org.apache.xmlgraphics:batik-anim:jar:1.7:compile 
| | | +- (xml-apis:xml-apis:jar:2.0.2:compile - version managed from 1.0.b2; omitted for duplicate) 
| | | \- (xml-apis:xml-apis-ext:jar:1.3.04:compile - omitted for duplicate) 
| | +- org.apache.xmlgraphics:batik-css:jar:1.7:compile 
| | | +- (xml-apis:xml-apis:jar:2.0.2:compile - version managed from 1.0.b2; omitted for duplicate) 
| | | \- (xml-apis:xml-apis-ext:jar:1.3.04:compile - omitted for duplicate) 
| | +- org.apache.xmlgraphics:batik-ext:jar:1.7:compile 
| | | \- (xml-apis:xml-apis:jar:2.0.2:compile - version managed from 1.0.b2; omitted for duplicate) 
| | +- (xml-apis:xml-apis:jar:2.0.2:compile - version managed from 1.0.b2; omitted for duplicate) 
| | \- (xml-apis:xml-apis-ext:jar:1.3.04:compile - omitted for duplicate) 
| +- org.apache.xmlgraphics:batik-dom:jar:1.7:compile 
| | +- (xml-apis:xml-apis:jar:2.0.2:compile - version managed from 1.0.b2; omitted for duplicate) 
| | \- (xml-apis:xml-apis-ext:jar:1.3.04:compile - omitted for duplicate) 
| +- org.apache.xmlgraphics:batik-gvt:jar:1.7:compile 
| | \- (xml-apis:xml-apis:jar:2.0.2:compile - version managed from 1.0.b2; omitted for duplicate) 
| +- org.apache.xmlgraphics:batik-svg-dom:jar:1.7:compile 
| | +- (xml-apis:xml-apis:jar:2.0.2:compile - version managed from 1.0.b2; omitted for duplicate) 
| | \- (xml-apis:xml-apis-ext:jar:1.3.04:compile - omitted for duplicate) 
| +- org.apache.xmlgraphics:batik-svggen:jar:1.7:compile 
| | \- (xml-apis:xml-apis:jar:2.0.2:compile - version managed from 1.0.b2; omitted for duplicate) 
| +- (xml-apis:xml-apis:jar:2.0.2:compile - version managed from 1.0.b2; omitted for duplicate) 
| \- xml-apis:xml-apis-ext:jar:1.3.04:compile 
\- xml-apis:xml-apis:jar:2.0.2:compile 

爲什麼我在dependencyManagment明確的版本被忽略?爲什麼設置會減少我的類路徑上的版本?我怎樣才能通過maven-enforcer-plugin與最新的xml-apis版本?

+0

您究竟如何檢查您的類路徑上的哪個版本? – 2015-03-30 19:46:16

+0

@TavianBarnes以'exec:exec'運行並打印System.getProperty(「java.class.path」)。 maven jar的版本號爲 – TheLQ 2015-03-30 19:47:52

回答

3

原來這不是maven問題,這是一個xml-api的問題。截至今天這是怎麼了xml-apis:xml-apis看起來Maven的中央

Very confusing xml-apis versions

如果你仔細看2.0.2不是最新版本,1.4.01是!當其他人和他們的IDE認爲2大於1時,xml-apis會倒退。

這是非常混亂和不明顯,所以希望有人認爲這有用。

+0

如果你看看2.0.0和2.0.2的POM文件,它們被「重新定位」到版本1.0.b2 這是一個巨大的混亂,並且混淆了很多構建工具和腳本。 XML的API XML的API 1.0.b2 ajeans 2018-02-13 09:13:27