问题
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