SLF4J: Class path contains multiple SLF4J bindings.

SLF4J: Class path contains multiple SLF4J bindings.

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/86186/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/86186/.m2/repository/org/slf4j/slf4j-log4j12/1.7.30/slf4j-log4j12-1.7.30.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 [ch.qos.logback.classic.util.ContextSelectorStaticBinder]

java编译执行报SLF4J的重复绑定,虽不影响执行;但是红色的错误提示还是不能忍;

查看包依赖

    1,项目使用mvn。执行个“mvn dependency:tree“的命令,查看项目包依赖关系;找出重复绑定的SLF4J的jar包。

命令大概结果如下:

[INFO] - org.apache.zookeeper:zookeeper:jar:3.5.7:compile
[INFO]    +- org.apache.zookeeper:zookeeper-jute:jar:3.5.7:compile
[INFO]    +- org.apache.yetus:audience-annotations:jar:0.5.0:compile
[INFO]    +- io.netty:netty-handler:jar:4.1.45.Final:compile
[INFO]    |  +- io.netty:netty-buffer:jar:4.1.45.Final:compile
[INFO]    |  - io.netty:netty-codec:jar:4.1.45.Final:compile
[INFO]    +- io.netty:netty-transport-native-epoll:jar:4.1.45.Final:compile
[INFO]    |  - io.netty:netty-transport-native-unix-common:jar:4.1.45.Final:compile
[INFO]    - org.slf4j:slf4j-log4j12:jar:1.7.30:compile

结合最后几次追加的POM的包,大概就很轻松定位冲突的包;

解决方法

pox文件添加exclusions;本人是添加zookeeper包造成的冲突。再里面加上exclusions再次启动程序,干净了!

     <dependency>
            <groupId>org.apache.zookeeper</groupId>
            <artifactId>zookeeper</artifactId>
            <version>${zookeeper.version}</version>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

 

hmoban主题是根据ripro二开的主题,极致后台体验,无插件,集成会员系统
自学咖网 » SLF4J: Class path contains multiple SLF4J bindings.