为什么 Maven 下载 log4j-1.2.12.jar?
Why is Maven downloading log4j-1.2.12.jar?
我正在尝试从我的 maven 项目中删除所有易受攻击的 log4j 依赖项。
我在我的 pom 中使用 log4j 2.16 依赖项,并在其他依赖项中添加了 log4j 和 sl4j 的排除项。
不过,每当我 运行 maven 包目标时,它都会下载 log4j 1.2.12 jar。
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ Test ---
Downloading: https://repo.maven.apache.org/maven2/log4j/log4j/1.2.12/log4j-1.2.12.pom
Downloaded: https://repo.maven.apache.org/maven2/log4j/log4j/1.2.12/log4j-1.2.12.pom (145 B at 0.1 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/log4j/log4j/1.2.12/log4j-1.2.12.jar
Downloaded: https://repo.maven.apache.org/maven2/log4j/log4j/1.2.12/log4j-1.2.12.jar (350 KB at 101.6 KB/sec)
我什至 运行 mvn dependency:tree
命令,它只显示 log4j 2.16.
它下载 log4j 1.2.12 jar 的原因可能是什么?
TL;DR: 这不是安全问题,但如果您认为是,请升级您的 maven-compiler-plugin
.
Maven plugins, i.e. the libraries that perform the actual work in building your project have also dependencies: log4j-1.2.12 is a (transitive) dependency of maven-compiler-plugin-3.1,您的项目使用。
因此,Maven 下载 log4j
的事实 而不是 意味着它将与您的应用程序一起打包。
备注:maven-compiler-plugin
的3.1版本是比较旧的版本。此版本在 default lifecycle bindings 中指定,出于兼容性原因永远不会升级。尽管如此,您应该在 POM 文件中指定更新的版本,例如:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
较新版本的 maven-compiler-plugin
没有 log4j:log4j
依赖项。
我正在尝试从我的 maven 项目中删除所有易受攻击的 log4j 依赖项。
我在我的 pom 中使用 log4j 2.16 依赖项,并在其他依赖项中添加了 log4j 和 sl4j 的排除项。
不过,每当我 运行 maven 包目标时,它都会下载 log4j 1.2.12 jar。
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ Test ---
Downloading: https://repo.maven.apache.org/maven2/log4j/log4j/1.2.12/log4j-1.2.12.pom
Downloaded: https://repo.maven.apache.org/maven2/log4j/log4j/1.2.12/log4j-1.2.12.pom (145 B at 0.1 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/log4j/log4j/1.2.12/log4j-1.2.12.jar
Downloaded: https://repo.maven.apache.org/maven2/log4j/log4j/1.2.12/log4j-1.2.12.jar (350 KB at 101.6 KB/sec)
我什至 运行 mvn dependency:tree
命令,它只显示 log4j 2.16.
它下载 log4j 1.2.12 jar 的原因可能是什么?
TL;DR: 这不是安全问题,但如果您认为是,请升级您的 maven-compiler-plugin
.
Maven plugins, i.e. the libraries that perform the actual work in building your project have also dependencies: log4j-1.2.12 is a (transitive) dependency of maven-compiler-plugin-3.1,您的项目使用。
因此,Maven 下载 log4j
的事实 而不是 意味着它将与您的应用程序一起打包。
备注:maven-compiler-plugin
的3.1版本是比较旧的版本。此版本在 default lifecycle bindings 中指定,出于兼容性原因永远不会升级。尽管如此,您应该在 POM 文件中指定更新的版本,例如:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
较新版本的 maven-compiler-plugin
没有 log4j:log4j
依赖项。