【问题】maven中设置不引入子依赖

5 篇文章 0 订阅

问题

在编译某些开源项目时,会提示如下内容:

Require upper bound dependencies error for io.airlift:aircompressor:0.15 paths to dependency are:
+-io.hetu.core:presto-vv:1.3.0
  +-io.hetu.core:presto-main:1.3.0
    +-io.airlift:aircompressor:0.15 (managed) <-- io.airlift:aircompressor:0.16
and
+-io.hetu.core:presto-vv:1.3.0
  +-org.apache.pulsar:managed-ledger:2.8.0
    +-org.apache.pulsar:pulsar-common:2.8.0
      +-io.airlift:aircompressor:0.15 (managed) <-- io.airlift:aircompressor:0.16
and
+-io.hetu.core:presto-vv:1.3.0
  +-io.hetu.core:presto-main:1.3.0
    +-io.hetu.core:hetu-transport:1.3.0
      +-io.airlift:aircompressor:0.15 (managed) <-- io.airlift:aircompressor:0.16
and
+-io.hetu.core:presto-vv:1.3.0
  +-io.hetu.core:presto-tests:1.3.0
    +-io.hetu.core:presto-main:1.3.0
      +-io.airlift:aircompressor:0.15 (managed) <-- io.airlift:aircompressor:0.16
,
Require upper bound dependencies error for com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.11.4 paths to dependency are:
+-io.hetu.core:presto-vv:1.3.0
  +-org.apache.pulsar:managed-ledger:2.8.0
    +-org.apache.pulsar:pulsar-common:2.8.0
      +-com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.11.4 (managed) <-- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.12.3
]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.581 s
[INFO] Finished at: 2021-09-15T14:53:10+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M3:enforce (default) on project presto-vv: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [Hel
p 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

原因及解决方法

这种一般是开启了依赖检查,检查时发现引入的多个依赖中都包含相同的子依赖,而且版本不一致。

所以可以通过设置在某些依赖中排除相同依赖的方法进行解决,如下示例中在kafka依赖中排除log4j等依赖:

<dependency>
    <groupId>org.apache.kafka</groupId>
    <artifactId>kafka_2.10</artifactId>
    <version>${dep.kafka.version}</version>
    <exclusions>
        <exclusion>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
        </exclusion>
        <exclusion>
            <artifactId>zookeeper</artifactId>
            <groupId>org.apache.zookeeper</groupId>
        </exclusion>
        <exclusion>
            <artifactId>netty</artifactId>
            <groupId>io.netty</groupId>
        </exclusion>
        <exclusion>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
        </exclusion>
    </exclusions>
</dependency>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值