Grails 应用程序中的 Log4J 问题依赖于 commons-logging

发布于 2025-01-05 21:31:50 字数 741 浏览 1 评论 0 原文

我正在向我的 Grails 项目添加一个依赖项,该项目将 commons-logging 和 log4j 作为传递依赖项引入。当我运行我的应用程序时,我收到一个错误

Error Error executing script RunApp: Could not initialize class
org.apache.log4j.LogManager (NOTE: Stack trace has been filtered. Use --verbose to see 
entiretrace.) java.lang.NoClassDefFoundError: Could not initialize class 
org.apache.log4j.LogManager

,我尝试按照 此链接,排除公共日志记录。但这从来没有帮助。我发现 commons-logging 不是我添加的依赖项的直接依赖项。那么,

    runtime ('com.company.i18n:i18n:1.3.4')
    { 
        excludes 'commons-logging'
    }

它是否会排除我的依赖项中的所有公共日志依赖项?或者只是直接的。我该如何解决这个问题?

I am adding a dependency to my Grails Project which brings in both commons-logging and log4j as transitive dependencies. When I run my app I then get an error

Error Error executing script RunApp: Could not initialize class
org.apache.log4j.LogManager (NOTE: Stack trace has been filtered. Use --verbose to see 
entiretrace.) java.lang.NoClassDefFoundError: Could not initialize class 
org.apache.log4j.LogManager

I tried to remove the commons-logging dependency as per this link by excluding the commons-logging. But it never helped. I see that commons-logging is not a direct dependency of the dependency I am adding. So if do

    runtime ('com.company.i18n:i18n:1.3.4')
    { 
        excludes 'commons-logging'
    }

does it exclude all the commons-logging dependencies in my dependency ? Or only the immediate ones. How do I solve this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

伪心 2025-01-12 21:31:50

我努力尝试从所有依赖项中排除“log4j”,但没有任何效果。最后,我通过避免所有传递依赖项然后添加必要的内容来解决这个问题。

//add necessary dependencies.

runtime ('com.company.i18n:i18n:1.3.4')
{ 
    transitive = false
}

I tried hard by excluding "log4j" from all the dependencies, but nothing worked. Finally I solved this by avoiding all the transitive dependencies and then adding what ever was necessary.

//add necessary dependencies.

runtime ('com.company.i18n:i18n:1.3.4')
{ 
    transitive = false
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文