gpt4 book ai didi

java - SLF4J:slf4j-api 1.6.x(或更高版本)与此绑定(bind)不兼容

转载 作者:搜寻专家 更新时间:2023-10-30 21:30:59 29 4
gpt4 key购买 nike

2015-09-28 10:02:21,890 ERROR [STDERR] (HDScanner) SLF4J: slf4j-api 1.6.x (or later) is incompatible with this binding.
2015-09-28 10:02:21,891 ERROR [STDERR] (HDScanner) SLF4J: Your binding is version 1.5.5 or earlier.
2015-09-28 10:02:21,891 ERROR [STDERR] (HDScanner) SLF4J: Upgrade your binding to version 1.6.x.
2015-09-28 10:02:21,891 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/metasolv-web]] (HDScanner) Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.NoSuchMethodError: org.slf4j.impl.StaticLoggerBinder.getSingleton()Lorg/slf4j/impl/StaticLoggerBinder;

如何修复此错误?另外,在我的应用程序中,我没有在任何地方使用 slf4j,只有 Dozer 库使用它。从下面的堆栈跟踪中,我看到 spring 应用程序正在使用 slf4j,但为什么它不自己加载一个?

java.lang.NoSuchMethodError: org.slf4j.impl.StaticLoggerBinder.getSingleton()Lorg/slf4j/impl/StaticLoggerBinder;
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:107)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:295)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269)
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:156)
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:645)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:191)

最佳答案

我不得不从 dozer 库中排除 slf4j 依赖项,并将依赖项直接添加到 POM 文件中。

如@Powerlord 所述,我必须添加两个库,一个用于核心 slf4j,另一个是绑定(bind)库。

下面的 Maven 依赖项。

       <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.6</version>
</dependency>

<dependency>
<groupId>net.sf.dozer</groupId>
<artifactId>dozer</artifactId>
<version>5.5.1</version>
<exclusions>
<exclusion>
<artifactId>jcl-over-slf4j</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>

关于java - SLF4J:slf4j-api 1.6.x(或更高版本)与此绑定(bind)不兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32826250/

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