Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java SLF4J:没有绑定,然后是多个绑定,试图绑定到Log4J_Java_Maven_Slf4j - Fatal编程技术网

Java SLF4J:没有绑定,然后是多个绑定,试图绑定到Log4J

Java SLF4J:没有绑定,然后是多个绑定,试图绑定到Log4J,java,maven,slf4j,Java,Maven,Slf4j,我对SLF4J有一个奇怪的双重错误 我正在尝试让SLF4J绑定到Log4J 在Eclipse中,当我运行Maven Clean和Maven安装时,我在Maven安装输出中得到: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/co

我对SLF4J有一个奇怪的双重错误

我正在尝试让SLF4J绑定到Log4J

在Eclipse中,当我运行Maven Clean和Maven安装时,我在Maven安装输出中得到:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
稍后,在为项目运行jUnit测试时,其中一个测试调用了一个记录消息的方法(我还没有将其清理为not log)。
但我得到的不是日志,而是这样的信息:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/JDunn/.m2/repository/ch/qos/logback/logback-classic/0.9.30/logback-classic-0.9.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/JDunn/.m2/repository/org/slf4j/slf4j-log4j13/1.0.1/slf4j-log4j13-1.0.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
所以,似乎SLF4J首先无法加载绑定,然后它会找到多个绑定

在我的pom.xml中,我只有一个相关依赖项:

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j13</artifactId>
    <version>1.0.1</version>
</dependency>
我运行了另一个Maven Clean,Maven Install,当它试图运行测试时,出现了一个奇怪的错误:

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.14:test (default-test) on project sonar-score-plugin: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.14:test failed: There was an error in the forked process
然后,我再次运行Maven Clean、Maven Install,再次出现原始的“多绑定”错误,发现我删除的目录再次出现,就好像我没有删除它一样

我不知道还能做些什么来消除“多绑定”错误

注意:我发现了一个错误,但我没有影响此错误的相同原因


另外,顶部的“找不到绑定器”错误可能是因为,尽管我不确定。

在我看来,您的测试依赖项中有多个绑定(作为依赖项的依赖项显式或隐式)

您的“正常”(非测试)依赖项没有相同的问题-实际上不包括单个SFL4j绑定


注意,我不是Maven或Eclipse的用户,不知道如何解决这个问题。我只是指出问题的根源,希望a)我是对的,b)这足以让你解决剩下的问题。

事实证明,我项目中的另一个依赖项(我们称之为依赖项a)在其自身的依赖项中,依赖于
ch.qos.logback:logback classic。
将此依赖项的排除项添加到依赖项a会导致错误,因此我决定放弃尝试绑定到
log4j
,只让它绑定到
logback classic
。 我删除了依赖项:slf4j-log4j13然后将其替换为:slf4j api这删除了多绑定错误


我假设没有绑定的顶部错误消息是由于它是在下载依赖项的依赖项之前给出的。所以我将忽略它,因为我的代码工作得很好。

您使用Eclipse作为IDE吗。?如果是,您使用的是哪个版本的m2e。?
Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.14:test (default-test) on project sonar-score-plugin: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.14:test failed: There was an error in the forked process
slf4j-log4j13 slf4j-api