有没有办法为 hadoop-hdfs 3.2.1 jar 覆盖 log4j 1.2.17 到 log4j2 的传递依赖

Is there way to override transitive dependency of log4j 1.2.17 to log4j2 for hadoop-hdfs 3.2.1 jar

我们正在使用 hadoop-hdfs 3.2.1 jar,它对 log4j 1.2.17 具有传递依赖性。在我们的中央 NexusIQ 扫描中,它给出了 log4j 依赖性的第 9 级问题。有没有办法将 log4j 覆盖为 log4j2 或任何其他解决方案。 我尝试了依赖管理,但在 log4j2 中没有带有工件 ID log4j 的 jar 来覆盖传递依赖。

简短回答:不,那不可能。您没有办法在 Nexus 级别覆盖传递依赖。您必须使用不同版本的 hadoop-hdfs,或者使用 "safe" log4j 版本自行编译。

我确实设法解决了 hbase-shaded-client jar 的类似问题,我不得不排除 log4j 1.2.17 依赖项。

为此,我做到了。

 <dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-client</artifactId>
<version>...</version>
<exclusions>
  <exclusion>
    <artifactId>log4j</artifactId>
    <groupId>log4j</groupId>
  </exclusion>
</exclusions>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>1.7.25</version>

成功了。