问题
在编译某些开源项目时,会提示如下内容:
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>