gpt4 book ai didi

java - 多个 SLF4J 绑定(bind)

转载 作者:行者123 更新时间:2023-11-30 08:07:32 30 4
gpt4 key购买 nike

我的类路径中有两个 jar 文件,它们与 slf4j 有依赖关系。这会在我的 Java 程序中导致一条警告消息:

 SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/lib/slf4j-log4j12-1.7.6.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/lib/myprogram.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]

有没有办法通过只更改 gradle 文件而不从我的类路径中删除上述任何 jar 文件来删除此警告消息?

谢谢

最佳答案

Is there a way to remove this warning message by only changing the gradle file, and without removing any of above jar files from my classpath?

没有。

消除该警告的唯一方法是只为 SLF4J 提供一个绑定(bind)。 And you really should do so:

Even when multiple bindings are present, SLF4J will pick one logging framework/implementation and bind with it. The way SLF4J picks a binding is determined by the JVM and for all practical purposes should be considered random.

由于您在自己的 jar 中提供了绑定(bind),因此将自己限制为单个绑定(bind)的最简单方法是排除 slf4j-log4j12-1.7.6.jar。

关于java - 多个 SLF4J 绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33640476/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com