Maven - transitive dependencies with different versions

若如初见. 提交于 2019-12-28 13:45:33

问题


  • Let's assume my application needs foo.jar and bar.jar
  • foo.jar needs version 1.0 of c.jar
  • bar.jar needs version 2.0 of c.jar

How does Maven resolve this conflict? Which version of c.jar will be used?


回答1:


It depends on the order of declaration in your effective POM. If foo.jar shows up first you will get version 1.0 of c.jar. If on the other hand bar.jar is declared first it will be version 2.0 of c.jar.

Relevant documentation:

...two dependency versions are at the same depth in the dependency tree, until Maven 2.0.8 it was not defined which one would win, but since Maven 2.0.9 it's the order in the declaration that counts: the first declaration wins



来源:https://stackoverflow.com/questions/8023646/maven-transitive-dependencies-with-different-versions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!