簡體   English   中英

試圖排除傳遞 Log4j 依賴

[英]Trying to exclude transitive Log4j dependency

所以我看到其他帖子(例如Can't use hbase-shaded-client jar because its internal dependency to log4j-1.2.17(CVE-2019-1757) )說他們有辦法排除傳遞依賴的log4j:log4j:1.2.17但是如果我運行./gradlew app:dependencies我仍然可以看到傳遞依賴項存在。

在此處輸入圖像描述

I have tried referring to the following migration doc https://logging.apache.org/log4j/2.x/manual/migration.html but Im not sure if this is just transferring the calls over from log4j 1.x over to 2 .x 在運行時或者如果它應該一起更新傳遞依賴。 我什至嘗試在我的 build.gradle 文件中排除傳遞依賴並使用 slf4j ,如下所示:

compile ('custom-library-that-I-cant-change-code-in'), {
            exclude group: 'log4j', module: 'log4j'
        }
// https://mvnrepository.com/artifact/org.slf4j/log4j-over-slf4j
implementation 'org.slf4j:log4j-over-slf4j:1.7.35'

我如何確定這是否有效,或者至少不使用舊的log4j:log4j:1.2.17還是我要解決這一切都錯了,有一種更簡單的方法可以做到這一點

回答你的第一個問題,如果,

compile ('custom-library-that-I-cant-change-code-in'), {
            exclude group: 'log4j', module: 'log4j'
        }

在你的 build.gradle 中試試這個

configurations {
    compile.exclude group: "log4j", module: "log4j"
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM