Java 与日志库冲突-类路径包含多个SLF4J绑定

Java 与日志库冲突-类路径包含多个SLF4J绑定,java,maven,logback,conflicting-libraries,logstash-logback-encoder,Java,Maven,Logback,Conflicting Libraries,Logstash Logback Encoder,我与日志库有冲突,但我不知道排除什么以及排除在哪里 这是我的pom: <dependency> <groupId>net.logstash.logback</groupId> <artifactId>logstash-logback-encoder</artifactId> <version>6.2</version> </dependency>

我与日志库有冲突,但我不知道排除什么以及排除在哪里

这是我的pom:

<dependency>
        <groupId>net.logstash.logback</groupId>
        <artifactId>logstash-logback-encoder</artifactId>
        <version>6.2</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <!--<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
        <optional>true</optional>
    </dependency>-->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>mssql-jdbc</artifactId>
        <version>7.4.1.jre8</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>com.github.lambdaexpression</groupId>
        <artifactId>request-body-param</artifactId>
        <version>2.0.2.RELEASE</version>
    </dependency>
</dependencies>

在有效pom中查找slf4j依赖项的父项。或者您也可以签入依赖关系树,该树可以由
mvn dependency:tree
生成


找到slf4j的父依赖项后,您可以添加排除项。

我的依赖项中有,我删除了它,现在可以全部使用。

我知道,但不能使用。是org.apache.cxf,但是如果我排除了slf4j不工作,如果我排除了logback classic工作,但是我需要logback classic用于logstash logback编码器为什么logback classic没有列在依赖关系树中?很抱歉,我当时排除了它,我更新了树,非常感谢。您是将应用程序作为spring boot应用程序运行还是部署到服务器?您是否尝试排除org.apache.logging.log4j:log4j-to-slf4j?我仍然觉得依赖关系树和错误日志不匹配。可能您可以生成依赖关系树,也可以使用完全相同的pom构建/运行应用程序,并在此处更新依赖关系树和错误日志?我部署到服务器,pom正确且错误正确,排除org.apache.logging.log4j:log4j-to-slf4j where?非常感谢您的帮助,老实说,我不知道为什么会有这种依赖性。我也有类似的问题,我可以在错误消息中看到冲突的绑定。但SLF4J并没有在我的项目pom中配置,这意味着它是传递性的。因此,我不确定如何排除其中一个冲突绑定。
[INFO] +- com.sun.xml.ws:jaxws-rt:pom:2.3.2:compile
[INFO] |  +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.2:compile
[INFO] |  +- jakarta.xml.ws:jakarta.xml.ws-api:jar:2.3.2:compile
[INFO] |  +- jakarta.xml.soap:jakarta.xml.soap-api:jar:1.4.1:compile
[INFO] |  +- jakarta.annotation:jakarta.annotation-api:jar:1.3.4:compile
[INFO] |  +- jakarta.jws:jakarta.jws-api:jar:1.1.1:compile
[INFO] |  +- org.glassfish.jaxb:jaxb-runtime:jar:2.3.1:compile
[INFO] |  |  +- org.glassfish.jaxb:txw2:jar:2.3.1:compile
[INFO] |  |  +- com.sun.istack:istack-commons-runtime:jar:3.0.7:compile
[INFO] |  |  \- javax.activation:javax.activation-api:jar:1.2.0:compile
[INFO] |  +- com.sun.xml.ws:policy:jar:2.7.6:compile
[INFO] |  +- org.glassfish.gmbal:gmbal:jar:4.0.0:compile
[INFO] |  |  +- org.glassfish.external:management-api:jar:3.2.1:compile
[INFO] |  |  +- org.glassfish.pfl:pfl-basic:jar:4.0.1:compile
[INFO] |  |  +- org.glassfish.pfl:pfl-tf:jar:4.0.1:compile
[INFO] |  |  |  +- org.glassfish.pfl:pfl-asm:jar:4.0.1:compile
[INFO] |  |  |  \- org.glassfish.pfl:pfl-dynamic:jar:4.0.1:compile
[INFO] |  |  +- org.glassfish.pfl:pfl-basic-tools:jar:4.0.1:compile
[INFO] |  |  \- org.glassfish.pfl:pfl-tf-tools:jar:4.0.1:compile
[INFO] |  +- org.jvnet.staxex:stax-ex:jar:1.8.1:compile
[INFO] |  +- com.sun.xml.stream.buffer:streambuffer:jar:1.5.7:compile
[INFO] |  +- org.jvnet.mimepull:mimepull:jar:1.9.11:compile
[INFO] |  +- com.sun.xml.fastinfoset:FastInfoset:jar:1.2.16:compile
[INFO] |  +- org.glassfish.ha:ha-api:jar:3.1.12:compile
[INFO] |  +- com.sun.xml.messaging.saaj:saaj-impl:jar:1.5.0:compile
[INFO] |  +- com.fasterxml.woodstox:woodstox-core:jar:5.0.3:compile
[INFO] |  +- org.codehaus.woodstox:stax2-api:jar:4.1:compile
[INFO] |  \- jakarta.activation:jakarta.activation-api:jar:1.2.1:compile
[INFO] +- javax.xml.ws:jaxws-api:jar:2.3.1:compile
[INFO] |  +- javax.xml.bind:jaxb-api:jar:2.3.1:compile
[INFO] |  +- javax.xml.soap:javax.xml.soap-api:jar:1.4.0:compile
[INFO] |  \- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] +- com.sun.xml.ws:jaxws-ri:pom:2.3.2:compile
[INFO] |  +- com.sun.xml.ws:jaxws-rt:jar:2.3.2:compile
[INFO] |  +- com.sun.xml.ws:jaxws-tools:jar:2.3.2:compile
[INFO] |  |  +- com.sun.xml.bind:jaxb-xjc:jar:2.3.2:compile
[INFO] |  |  \- com.sun.xml.bind:jaxb-jxc:jar:2.3.2:compile
[INFO] |  +- com.sun.xml.ws:jaxws-eclipselink-plugin:jar:2.3.2:compile
[INFO] |  |  +- jakarta.mail:jakarta.mail-api:jar:1.6.3:compile
[INFO] |  |  +- jakarta.persistence:jakarta.persistence-api:jar:2.2.2:compile
[INFO] |  |  \- org.eclipse.persistence:org.eclipse.persistence.moxy:jar:2.7.4:compile
[INFO] |  |     \- org.eclipse.persistence:org.eclipse.persistence.core:jar:2.7.4:compile
[INFO] |  |        \- org.eclipse.persistence:org.eclipse.persistence.asm:jar:2.7.4:compile
[INFO] |  +- com.sun.xml.ws:sdo-eclipselink-plugin:jar:2.3.2:compile
[INFO] |  |  +- org.eclipse.persistence:org.eclipse.persistence.sdo:jar:2.7.4:compile
[INFO] |  |  \- org.eclipse.persistence:commonj.sdo:jar:2.1.1:compile
[INFO] |  +- com.sun.xml.ws:release-documentation:zip:docbook:2.3.2:compile
[INFO] |  \- com.sun.xml.ws:samples:zip:2.3.2:compile
[INFO] +- com.sun.org.apache.xml.internal:resolver:jar:20050927:compile
[INFO] +- org.apache.cxf:cxf-spring-boot-starter-jaxws:jar:3.3.3:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter:jar:2.1.9.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot:jar:2.1.9.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-autoconfigure:jar:2.1.9.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.1.9.RELEASE:compile
[INFO] |  |  |  +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] |  |  |  |  \- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] |  |  |  \- org.slf4j:jul-to-slf4j:jar:1.7.28:compile
[INFO] |  |  \- org.yaml:snakeyaml:jar:1.23:runtime
[INFO] |  +- org.apache.cxf:cxf-spring-boot-autoconfigure:jar:3.3.3:compile
[INFO] |  +- org.apache.cxf:cxf-rt-transports-http:jar:3.3.3:compile
[INFO] |  |  \- org.apache.cxf:cxf-core:jar:3.3.3:compile
[INFO] |  |     \- org.apache.ws.xmlschema:xmlschema-core:jar:2.2.4:compile
[INFO] |  +- org.apache.cxf:cxf-rt-frontend-jaxws:jar:3.3.3:compile
[INFO] |  |  +- xml-resolver:xml-resolver:jar:1.2:compile
[INFO] |  |  +- org.ow2.asm:asm:jar:7.1:compile
[INFO] |  |  +- org.apache.cxf:cxf-rt-bindings-soap:jar:3.3.3:compile
[INFO] |  |  |  +- org.apache.cxf:cxf-rt-wsdl:jar:3.3.3:compile
[INFO] |  |  |  |  \- wsdl4j:wsdl4j:jar:1.6.3:compile
[INFO] |  |  |  \- org.apache.cxf:cxf-rt-databinding-jaxb:jar:3.3.3:compile
[INFO] |  |  +- org.apache.cxf:cxf-rt-bindings-xml:jar:3.3.3:compile
[INFO] |  |  +- org.apache.cxf:cxf-rt-frontend-simple:jar:3.3.3:compile
[INFO] |  |  \- org.apache.cxf:cxf-rt-ws-addr:jar:3.3.3:compile
[INFO] |  |     \- org.apache.cxf:cxf-rt-ws-policy:jar:3.3.3:compile
[INFO] |  |        \- org.apache.neethi:neethi:jar:3.1.1:compile
[INFO] |  +- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] |  +- com.sun.activation:javax.activation:jar:1.2.0:compile
[INFO] |  +- org.apache.geronimo.specs:geronimo-ws-metadata_2.0_spec:jar:1.1.3:compile
[INFO] |  +- org.jacorb:jacorb-omgapi:jar:3.7:compile
[INFO] |  +- org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1.1:compile
[INFO] |  \- org.jboss.spec.javax.rmi:jboss-rmi-api_1.0_spec:jar:1.0.6.Final:compile
[INFO] +- net.logstash.logback:logstash-logback-encoder:jar:6.2:compile
[INFO] |  \- com.fasterxml.jackson.core:jackson-databind:jar:2.9.9.3:compile
[INFO] |     +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
[INFO] |     \- com.fasterxml.jackson.core:jackson-core:jar:2.9.9:compile
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:2.1.9.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-aop:jar:2.1.9.RELEASE:compile
[INFO] |  |  \- org.aspectj:aspectjweaver:jar:1.9.4:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.1.9.RELEASE:compile
[INFO] |  |  +- com.zaxxer:HikariCP:jar:3.2.0:compile
[INFO] |  |  \- org.springframework:spring-jdbc:jar:5.1.10.RELEASE:compile
[INFO] |  +- javax.transaction:javax.transaction-api:jar:1.3:compile
[INFO] |  +- org.hibernate:hibernate-core:jar:5.3.12.Final:compile
[INFO] |  |  +- org.jboss.logging:jboss-logging:jar:3.3.3.Final:compile
[INFO] |  |  +- javax.persistence:javax.persistence-api:jar:2.2:compile
[INFO] |  |  +- org.javassist:javassist:jar:3.23.2-GA:compile
[INFO] |  |  +- net.bytebuddy:byte-buddy:jar:1.9.16:compile
[INFO] |  |  +- antlr:antlr:jar:2.7.7:compile
[INFO] |  |  +- org.jboss:jandex:jar:2.0.5.Final:compile
[INFO] |  |  +- com.fasterxml:classmate:jar:1.4.0:compile
[INFO] |  |  +- org.dom4j:dom4j:jar:2.1.1:compile
[INFO] |  |  \- org.hibernate.common:hibernate-commons-annotations:jar:5.0.4.Final:compile
[INFO] |  +- org.springframework.data:spring-data-jpa:jar:2.1.11.RELEASE:compile
[INFO] |  |  +- org.springframework.data:spring-data-commons:jar:2.1.11.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-orm:jar:5.1.10.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-context:jar:5.1.10.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-tx:jar:5.1.10.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-beans:jar:5.1.10.RELEASE:compile
[INFO] |  |  \- org.slf4j:slf4j-api:jar:1.7.28:compile
[INFO] |  \- org.springframework:spring-aspects:jar:5.1.10.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-security:jar:2.1.9.RELEASE:compile
[INFO] |  +- org.springframework:spring-aop:jar:5.1.10.RELEASE:compile
[INFO] |  +- org.springframework.security:spring-security-config:jar:5.1.6.RELEASE:compile
[INFO] |  \- org.springframework.security:spring-security-web:jar:5.1.6.RELEASE:compile
[INFO] |     \- org.springframework:spring-expression:jar:5.1.10.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.1.9.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-json:jar:2.1.9.RELEASE:compile
[INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.9:compile
[INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.9:compile
[INFO] |  |  \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.9:compile
[INFO] |  +- org.hibernate.validator:hibernate-validator:jar:6.0.17.Final:compile
[INFO] |  +- org.springframework:spring-web:jar:5.1.10.RELEASE:compile
[INFO] |  \- org.springframework:spring-webmvc:jar:5.1.10.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.1.9.RELEASE:provided
[INFO] |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.26:provided
[INFO] |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.26:provided
[INFO] |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.26:provided
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.1.9.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test:jar:2.1.9.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.1.9.RELEASE:test
[INFO] |  +- com.jayway.jsonpath:json-path:jar:2.4.0:test
[INFO] |  |  \- net.minidev:json-smart:jar:2.3:test
[INFO] |  |     \- net.minidev:accessors-smart:jar:1.2:test
[INFO] |  +- junit:junit:jar:4.12:test
[INFO] |  +- org.assertj:assertj-core:jar:3.11.1:test
[INFO] |  +- org.mockito:mockito-core:jar:2.23.4:test
[INFO] |  |  +- net.bytebuddy:byte-buddy-agent:jar:1.9.16:test
[INFO] |  |  \- org.objenesis:objenesis:jar:2.6:test
[INFO] |  +- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] |  +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO] |  +- org.skyscreamer:jsonassert:jar:1.5.0:test
[INFO] |  |  \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] |  +- org.springframework:spring-core:jar:5.1.10.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-jcl:jar:5.1.10.RELEASE:compile
[INFO] |  +- org.springframework:spring-test:jar:5.1.10.RELEASE:test
[INFO] |  \- org.xmlunit:xmlunit-core:jar:2.6.3:test
[INFO] +- org.springframework.security:spring-security-test:jar:5.1.6.RELEASE:test
[INFO] |  \- org.springframework.security:spring-security-core:jar:5.1.6.RELEASE:compile
[INFO] +- com.microsoft.sqlserver:mssql-jdbc:jar:7.4.1.jre8:runtime
[INFO] \- com.github.lambdaexpression:request-body-param:jar:2.0.2.RELEASE:compile
[INFO]    +- org.springframework.boot:spring-boot-starter-actuator:jar:2.1.9.RELEASE:compile
[INFO]    |  +- org.springframework.boot:spring-boot-actuator-autoconfigure:jar:2.1.9.RELEASE:compile
[INFO]    |  |  \- org.springframework.boot:spring-boot-actuator:jar:2.1.9.RELEASE:compile
[INFO]    |  \- io.micrometer:micrometer-core:jar:1.1.7:compile
[INFO]    |     +- org.hdrhistogram:HdrHistogram:jar:2.1.9:compile
[INFO]    |     \- org.latencyutils:LatencyUtils:jar:2.0.3:compile
[INFO]    +- com.alibaba:fastjson:jar:1.2.51:compile
[INFO]    \- com.google.api-client:google-api-client:jar:1.23.0:compile
[INFO]       +- com.google.oauth-client:google-oauth-client:jar:1.23.0:compile
[INFO]       |  +- com.google.http-client:google-http-client:jar:1.23.0:compile
[INFO]       |  |  \- org.apache.httpcomponents:httpclient:jar:4.5.10:compile
[INFO]       |  |     +- org.apache.httpcomponents:httpcore:jar:4.4.12:compile
[INFO]       |  |     \- commons-codec:commons-codec:jar:1.11:compile
[INFO]       |  \- com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO]       +- com.google.http-client:google-http-client-jackson2:jar:1.23.0:compile
[INFO]       \- com.google.guava:guava-jdk5:jar:17.0:compile