hsi*_*ngh 5 spring gradle log4j2 spring-boot
我可以在我的项目的 Gradle 依赖树中看到 org.apache.logging.log4j:log4j-core:2.14.0 库。
我们还没有从外部添加 log4j 版本。该版本作为其他 jar 或 spring-boot-starter 的传递依赖项的一部分出现。
如何在 Gradle 中覆盖 log4j 版本?
首先,找出您真正使用的 log4j 相关库,例如
.\gradlew dependencies --configuration=testRuntimeClasspath | find "log4j"
Run Code Online (Sandbox Code Playgroud)
然后用当前版本覆盖它们,如下所示(docs),放置在dependencies块之后:
configurations.all {
resolutionStrategy {
force 'org.apache.logging.log4j:log4j-api:2.17.0'
force 'org.apache.logging.log4j:log4j-core:2.17.0'
force 'org.apache.logging.log4j:log4j-slf4j-impl:2.17.0'
force 'org.apache.logging.log4j:log4j-jul:2.17.0'
}
}
Run Code Online (Sandbox Code Playgroud)
您可能需要向该块添加更多/更少的库,具体取决于开始时的检查结果。
由于您使用的是 Spring Boot,因此您还可以使用Spring-Boot 特定的功能来设置 Log4J 版本:
ext['log4j2.version'] = '2.17.0'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6747 次 |
| 最近记录: |