maven same transitive dependency but different version

耗尽温柔 提交于 2019-12-07 23:22:17

问题


I am running into a problem where I have the following 2 dependencies:

org.apache.felix » org.apache.felix.utils » 1.6.0

and

com.github.rotty3000 » phidias » 0.3.2

they both have transitive dependency on org.osgi.core, felix depends on version 4.1.0 and phidias depends on version 5.0.0

we need version 5.0.0 for our code to correctly compile

if I put my dependencies as:

<dependencies>
    <dependency>
        <groupId>org.apache.felix</groupId>
        <artifactId>org.apache.felix.utils</artifactId>
        <version>1.6.0</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.github.rotty3000</groupId>
        <artifactId>phidias</artifactId>
        <version>0.3.2</version>
        <scope>compile</scope>
    </dependency>
</dependencies>

maven automatically gets version 4.1.0 causing compile error. If I put phidias on top of felix it would get version 5.0.0 and compile fine.

we want to order the dependencies in alphabetical order so felix will go on top, is there anyway to force osgi.core to resolve the 5.0.0 version?

Thanks!


回答1:


<exclude> it from both of those dependency

add org.osgi.core's required dependency at version 5.0.0 in your pom.xml as an explicit dependency with your required version

make sure the two libraries you are consuming are runtime compatible with 5.0.0



来源:https://stackoverflow.com/questions/29979893/maven-same-transitive-dependency-but-different-version

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