2018.10.23
前言
A ---> B ---> C
|_____________↑
某個項目裏,A模塊依賴於B模塊和C模塊,B模塊也依賴於C模塊。它們各自都會依賴某些相同第三方庫,如hadoop-common,但版本不完全一致。
方法
一般是因爲依賴衝突。在這個case裏,通過分析dependencyTree(mvn dependency:tree > C:\dependencyTree.txt
1),發現是A和B分別依賴於不同版本的庫。在pom中exclude解決了該問題:
<dependency>
<groupId>B.groupId</group>
<artifactId>B.artifactId</artifactId>
<version>xx-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>conflict.groupId</groupId>
<artifactId>conflict.artifactId</artifactId>
</exclusion>
</exclusions>
</dependency>
參考閱讀
- https://blog.csdn.net/strawbingo/article/details/2474790
- http://files.zeroturnaround.com/pdf/Maven-cheat-sheet.pdf