SLF4J: Class path contains multiple SLF4J bindings. 問題の原因と解決方法.

3220 ワード

に質問


Springbootプロジェクトはslf 4 jを使用しており、zookeeperを導入するとエラーが発生します.
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/silence.hu/.m2/repository/org/slf4j/slf4j-log4j12/1.7.25/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/silence.hu/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.10.0/log4j-slf4j-impl-2.10.0.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 [org.slf4j.impl.Log4jLoggerFactory]

問題点から分かるように、複数のSLFJ実装バインディング:logback-classicslf4j-log4j12があるからである.私はzookeeperを導入してから報告した間違いなので、zookeeperを導入してから起きたjarパッケージの衝突に違いないので、zookeeperのslf4j-log4j12を排除すればいいです.

<dependency>
    <groupId>org.apache.zookeepergroupId>
    <artifactId>zookeeperartifactId>
    <exclusions>
        <exclusion>
            <groupId>org.slf4jgroupId>
            <artifactId>slf4j-log4j12artifactId>
        exclusion>
    exclusions>
dependency>