当前位置: 首页 > 知识库问答 >
问题:

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

郎子平
2023-03-14

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

这是我的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>

错误:

SLF4J:类路径包含多个SLF4J绑定。slf4j:在[jar:file:/c:/apache-cxf-3.3.4/lib/slf4j-jdk14-1.7.28.jar!/org/slf4j/impl/staticloggerbinder.class]中找到绑定slf4j:在[jar:file:/c:/users/u96712/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/staticloggerbinder.class]中找到绑定slf4j:SLF4J:线程“main”java.lang.IllegalArgumentException中的实际绑定类型为[org.slf4j.impl.jdk14LoggerFactory]异常:LoggerFactory不是一个LoggerContext,但Logback在类路径上。删除Logback或竞争实现(类org.slf4j.impl.jdk14LoggerFactory从文件:/c:/apache-cxf-3.3.4/lib/slf4j-jdk14-1.7.28.jar加载)。如果您正在使用WebLogic,则需要将“org.slf4j”添加到Web-inf/WebLogic.xml中的prefer-application-packages:org.slf4j.impl.jdk14loggerfactory(org.springframework.util.assert.instancecheckfailed(assert.java:655)(org.springframework.util.assert.isinstanceof(assert.java:555)(在org.springframework.context.event.simpleapplicationeventmulticaster.multicastevent(Simpleapplicationeventmulticaster.java:139)在org.springframework.context.event.simpleapplicationeventmulticaster.multicastevent(Simpleapplicationeventmulticaster.multicastevent(Simpleapplicationeventmulticaster.java:127)在

依赖树

[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

共有2个答案

方兴旺
2023-03-14

我在我的依赖项中有CXF运行时,我删除了它,现在全部工作。

方玄天
2023-03-14

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

找到slf4j的父依赖项后,可以添加excluion。

 类似资料: