Как избежать множественных привязок SLF4J?

Коллеги, когда я запускаю любой тест, я получаю следующую трассировку стека:

SLF4J: путь к классу содержит несколько привязок SLF4J. SLF4J: Обнаружена привязка в [jar:file:/C:/Users/someuser/.m2/repository/org/slf4j/slf4j-simple/1.7.22/slf4j-simple-1.7.22.jar!/ Org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Найдена привязка в [jar:file:/C:/Users/someuser/.m2/repository/ch/qos/logback/logback-classic/1.1.9/logback-classic-1.1.9.jar!/org/slf4j/impl/StaticLoggerBinder.class]

Мое дерево зависимостей выглядит так:

C:\Users\someuser\Documents\GIT\same-integration\same-ftp>mvn dependency:tree
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten t
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support buildin
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building same :: FTP 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ same-ftp ---
[INFO] com.ac.same:same-ftp:jar:1.0-SNAPSHOT
[INFO] +- org.springframework:spring-context:jar:4.3.5.RELEASE:compile
[INFO] |  +- org.springframework:spring-aop:jar:4.3.5.RELEASE:compile
[INFO] |  +- org.springframework:spring-beans:jar:4.3.5.RELEASE:compile
[INFO] |  +- org.springframework:spring-core:jar:4.3.5.RELEASE:compile
[INFO] |  \- org.springframework:spring-expression:jar:4.3.5.RELEASE:compile
[INFO] +- org.springframework:spring-tx:jar:4.3.5.RELEASE:compile
[INFO] +- org.springframework:spring-test:jar:4.3.5.RELEASE:test
[INFO] +- org.springframework:spring-orm:jar:4.3.5.RELEASE:compile
[INFO] |  \- org.springframework:spring-jdbc:jar:4.3.5.RELEASE:compile
[INFO] +- org.hibernate:hibernate-core:jar:5.2.6.Final:compile
[INFO] |  +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile
[INFO] |  +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Fin
[INFO] |  +- org.javassist:javassist:jar:3.20.0-GA:compile
[INFO] |  +- antlr:antlr:jar:2.7.7:compile
[INFO] |  +- org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1.1:compile
[INFO] |  +- org.jboss:jandex:jar:2.0.3.Final:compile
[INFO] |  +- com.fasterxml:classmate:jar:1.3.0:compile
[INFO] |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  +- org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:
[INFO] |  \- javax.enterprise:cdi-api:jar:1.1:compile
[INFO] |     +- javax.el:el-api:jar:2.2:compile
[INFO] |     +- org.jboss.spec.javax.interceptor:jboss-interceptors-api_1.1_spec
[INFO] |     +- javax.annotation:jsr250-api:jar:1.0:compile
[INFO] |     \- javax.inject:javax.inject:jar:1:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.1.9:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.7.22:compile
[INFO] +- ch.qos.logback:logback-core:jar:1.1.9:compile
[INFO] +- me.moocar:logback-gelf:jar:0.3:compile
[INFO] |  +- com.google.code.gson:gson:jar:2.3.1:compile
[INFO] |  \- me.moocar:socket-encoder-appender:jar:0.1beta1:compile
[INFO] +- org.slf4j:jul-to-slf4j:jar:1.7.22:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.7.22:compile
[INFO] +- com.typesafe:config:jar:1.3.0:compile
[INFO] +- commons-io:commons-io:jar:2.2:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.5:compile
[INFO] +- org.apache.camel:camel-core:jar:2.18.1:compile
[INFO] |  +- com.sun.xml.bind:jaxb-core:jar:2.2.11:compile
[INFO] |  \- com.sun.xml.bind:jaxb-impl:jar:2.2.11:compile
[INFO] +- org.apache.camel:camel-ftp:jar:2.18.1:compile
[INFO] |  \- commons-net:commons-net:jar:3.3:compile
[INFO] +- org.apache.camel:camel-spring:jar:2.18.1:compile
[INFO] +- org.apache.camel:camel-quartz2:jar:2.18.1:compile
[INFO] |  +- org.quartz-scheduler:quartz:jar:2.2.3:compile
[INFO] |  \- com.mchange:c3p0:jar:0.9.5.2:compile
[INFO] |     \- com.mchange:mchange-commons-java:jar:0.2.11:compile
[INFO] +- org.apache.camel:camel-jdbc:jar:2.18.1:compile
[INFO] +- com.jcraft:jsch:jar:0.1.42:compile
[INFO] +- junit:junit:jar:4.12:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- pl.touk:tsc-reload:jar:0.3.0:compile
[INFO] |  \- com.javaslang:javaslang:jar:2.0.0-RC3:compile
[INFO] +- commons-collections:commons-collections:jar:3.0:compile
[INFO] +- org.apache.maven.plugins:maven-shade-plugin:jar:2.4.3:compile
[INFO] |  +- org.apache.maven:maven-plugin-api:jar:3.0:compile
[INFO] |  |  \- org.sonatype.sisu:sisu-inject-plexus:jar:1.4.2:compile
[INFO] |  |     \- org.sonatype.sisu:sisu-inject-bean:jar:1.4.2:compile
[INFO] |  |        \- org.sonatype.sisu:sisu-guice:jar:noaop:2.1.7:compile
[INFO] |  +- org.apache.maven:maven-model:jar:3.0:compile
[INFO] |  +- org.apache.maven:maven-core:jar:3.0:compile
[INFO] |  |  +- org.apache.maven:maven-settings:jar:3.0:compile
[INFO] |  |  +- org.apache.maven:maven-settings-builder:jar:3.0:compile
[INFO] |  |  +- org.apache.maven:maven-repository-metadata:jar:3.0:compile
[INFO] |  |  +- org.apache.maven:maven-model-builder:jar:3.0:compile
[INFO] |  |  +- org.apache.maven:maven-aether-provider:jar:3.0:runtime
[INFO] |  |  +- org.sonatype.aether:aether-impl:jar:1.7:compile
[INFO] |  |  |  \- org.sonatype.aether:aether-spi:jar:1.7:compile
[INFO] |  |  +- org.sonatype.aether:aether-api:jar:1.7:compile
[INFO] |  |  +- org.sonatype.aether:aether-util:jar:1.7:compile
[INFO] |  |  +- org.codehaus.plexus:plexus-interpolation:jar:1.14:compile
[INFO] |  |  +- org.codehaus.plexus:plexus-classworlds:jar:2.2.3:compile
[INFO] |  |  +- org.codehaus.plexus:plexus-component-annotations:jar:1.5.5:compi
[INFO] |  |  \- org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3:compile
[INFO] |  |     \- org.sonatype.plexus:plexus-cipher:jar:1.4:compile
[INFO] |  +- org.apache.maven:maven-compat:jar:3.0:compile
[INFO] |  |  \- org.apache.maven.wagon:wagon-provider-api:jar:1.0-beta-6:compile
[INFO] |  +- org.apache.maven:maven-artifact:jar:3.0:compile
[INFO] |  +- org.codehaus.plexus:plexus-utils:jar:3.0.22:compile
[INFO] |  +- org.ow2.asm:asm:jar:5.0.2:compile
[INFO] |  +- org.ow2.asm:asm-commons:jar:5.0.2:compile
[INFO] |  |  \- org.ow2.asm:asm-tree:jar:5.0.2:compile
[INFO] |  +- org.jdom:jdom:jar:1.1:compile
[INFO] |  +- org.apache.maven.shared:maven-dependency-tree:jar:2.2:compile
[INFO] |  |  \- org.eclipse.aether:aether-util:jar:0.9.0.M2:compile
[INFO] |  +- org.vafer:jdependency:jar:1.1:compile
[INFO] |  |  +- org.ow2.asm:asm-analysis:jar:5.0.4:compile
[INFO] |  |  \- org.ow2.asm:asm-util:jar:5.0.4:compile
[INFO] |  \- com.google.guava:guava:jar:11.0.2:compile
[INFO] |     \- com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO] +- org.springframework:spring-context-support:jar:4.2.4.RELEASE:compile
[INFO] +- org.thymeleaf:thymeleaf:jar:3.0.2.RELEASE:compile
[INFO] |  +- ognl:ognl:jar:3.1.10:compile
[INFO] |  +- org.attoparser:attoparser:jar:2.0.1.RELEASE:compile
[INFO] |  \- org.unbescape:unbescape:jar:1.1.4.RELEASE:compile
[INFO] +- org.thymeleaf:thymeleaf-spring4:jar:3.0.2.RELEASE:compile
[INFO] +- javax.mail:mail:jar:1.4.7:compile
[INFO] |  \- javax.activation:activation:jar:1.1:compile
[INFO] +- org.apache.commons:commons-dbcp2:jar:2.1.1:compile
[INFO] |  \- org.apache.commons:commons-pool2:jar:2.4.2:compile
[INFO] \- com.microsoft.sqlserver:sqljdbc4:jar:4.2:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.583 s
[INFO] Finished at: 2017-02-15T13:42:27+03:00
[INFO] Final Memory: 20M/236M
[INFO] ------------------------------------------------------------------------

Я пытаюсь добавить любой exclusions но это не помогает

Можете ли вы сказать мне, как решить эту проблему?

1 ответ

Предполагая, что вы хотите использовать logback-classic, вам нужно исключить остальные:

<dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.2.6.Final</version>
            <exclusions>
                <exclusion>
                    <groupId>me.moocar:logback-gelf</groupId>
                    <artifactId>me.moocar:logback-gelf</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>jul-to-slf4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>jul-over-slf4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>me.moocar:logback-gelf</groupId>
                    <artifactId>me.moocar:logback-gelf</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
Другие вопросы по тегам