maven相同的传递依赖,但不同的版本 [英] maven same transitive dependency but different version

查看:739
本文介绍了maven相同的传递依赖,但不同的版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一个问题,我有以下2个依赖关系:

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

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

com.github.rotty3000»phidias»0.3.2

他们都具有对org.osgi.core的传递依赖,felix依赖版本4.1.0和phidias取决于版本5.0.0

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

我们需要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自动获取版本4.1.0导致编译错误。如果我把phidias放在felix的顶部,它会获得版本5.0.0并编译好。

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.

我们要按字母顺序排列依赖关系,所以felix会排在上面,有没有强制osgi.core解决5.0.0版本?

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?

谢谢!

推荐答案

< exclude> 这两个依赖关系

<exclude> it from both of those dependency

添加 org.osgi。在 pom.xml 中的版本 5.0.0 中的核心显式依赖于您所需的版本

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

确保您正在使用的两个库与 5.0.0

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

这篇关于maven相同的传递依赖,但不同的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆