gpt4 book ai didi

java - 多个 SLF4J 绑定(bind)会导致错误?

转载 作者:太空狗 更新时间:2023-10-29 23:01:48 27 4
gpt4 key购买 nike

我的依赖树和多个 SLF4J 绑定(bind)有问题。到目前为止我发现通常这只会引起警告但在我的情况下它似乎阻止我的程序运行:这些是我得到的异常(exception)情况:

SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/C:/Users/FischerNi/.m2/repository/org/slf4j/slf4j-jdk14/1.5.3/slf4j-jdk14-1.5.3.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/C:/Users/FischerNi/.m2/repository/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: slf4j-api 1.6.x (or later) is incompatible with this binding. SLF4J: Your binding is version 1.5.5 or earlier. SLF4J: Upgrade your binding to version 1.6.x. or 2.0.x Exception in thread "main" java.lang.NoSuchMethodError: org.slf4j.impl.StaticLoggerBinder.getSingleton()Lorg/slf4j/impl/StaticLoggerBinder;

这是我依赖项的相关部分: 网.lightbody.bmp 浏览器代理 2.0-beta-8

    <!-- LOGGING DEPENDENCIES - LOG4J -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>

有人可以告诉我如何解决这个问题吗?

最佳答案

有几个解决方案:

  • 确保您仅包含一个 slf4j jar(可能包含更高版本),如果您的类路径中有几个不同版本的话。
  • 有时可能无法排除多个 slf4j jar,因为它们可能在您的类路径上的其他 jar 内部使用。这些依赖的 jar 可能引用不同版本的 slf4j jar,这会导致您的应用程序失败。在这种情况下,确保在使用 SLF4J jar 的其他 jar 之前添加具有更高版本 SLF4j 的 jar。这将确保您的 Java 程序将选择最新版本的 SLF4J,这显然是向后兼容的。

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

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