TL; DR如何停止在Maven中覆蓋傳遞依賴的版本?
我有一個依賴管理問題。我想簡化我的問題的說明,所以我沒有要發佈的NoClassDefFoundError的全堆棧跟蹤:.. VeryImportantStuff等
簡單地說,我用2依賴性:A-1.1和B- 1.0我的項目C。我不能接受A或B的另一個版本。 B-1.0取決於A-1.0。 A的作者不尊重後向兼容性規則,A庫的最新版本(1.1)根本沒有類VeryImportantStuff.class
。
<dependency>
<groupId>org.thirdparty.lib</groupId>
<artifactId>A</artifactId>
<version>1.1</version> <!-- overrides B->A version !!! (((-->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.another.thirdparty.lib</groupId>
<artifactId>B</artifactId>
<version>1.0</version>
<scope>test</scope>
<!--
<dependencyManagement>
<dearMavenIbegYouPleaseUseThisDependency>
<dependency>
<groupId>org.thirdparty.lib</groupId>
<artifactId>A</artifactId>
<version>1.0</version> PLEASE!!!
</dependency>
</dearMavenIbegYouPleaseUseThisDependency>
</dependencyManagement>
-->
</dependency>
問題
如何分辨乙(或我可以添加到我的pom.xml的),它應該使用1.0版本A的,不屬於其規定的1.1 pom.xml考慮到我的應用程序代碼應該使用A-1.1?
如果* ... B-1.0依賴於A-1.0 *然後B-1.0是建立使用A的1.0只,爲了確保你的項目沒有得到1.0只是使用''在B的依賴關係 –
nullpointer
當B-1.0運行時,它在運行時無法找到所需的A-1.0的類。運行時有A-1.1類。 – ieXcept
你是什麼意思*當B-1.0運行*時?當你將它聲明爲一個依賴項時,假設它已經使用它自己的pom.xml中提到的依賴關係來構建。 – nullpointer