java 类路径包含多个 SLF4J 绑定

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39817610/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 04:39:36  来源:igfitidea点击:

Class path contains multiple SLF4J bindings

javamavenapache-stormslf4j

提问by user1

I tried to debug my project but got this

我试图调试我的项目,但得到了这个

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/storm/lib/logback-classic-1.0.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/user/.m2/repository/ch/qos/logback/logback-classic/1.0.13/logback-classic-1.0.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]

what should i do ?

我该怎么办 ?

i haven't any dependency for SLF4J in POM just this

我对 POM 中的 SLF4J 没有任何依赖,仅此而已

<dependency>
        <groupId>org.apache.storm</groupId>
        <artifactId>storm-core</artifactId>
        <version>0.9.6</version>
        <scope>provided</scope>
</dependency>

i tried to use the solutions i found in similar posts but didn't solve it ! like

我尝试使用我在类似帖子中找到的解决方案,但没有解决!喜欢

<exclusions>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>log4j-over-slf4j</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>logback-classic</groupId>
                <artifactId>ch.qos.logback</artifactId>
            </exclusion>
        </exclusions>

I tried to replace providedto compilebut didn't solve it too .

我试图替换providedcompile但也没有解决它。

I got this with using mvn dependency:tree

我得到了这个使用 mvn dependency:tree

 org.slf4j:log4j-over-slf4j:jar:1.6.6:provided 
 org.slf4j:slf4j-api:jar:1.7.5:compile

采纳答案by Issam EL-ATIF

You have 2 sources of dependencies for storm one from /usr/local/storm/lib/ directory and the second from maven which cause multiple binding for sl4j.
Try using just one source of dependencies.

您有 2 个风暴依赖源,一个来自 /usr/local/storm/lib/ 目录,第二个来自 maven,这会导致 sl4j 的多重绑定。
尝试只使用一种依赖源。