SLF4J的多个绑定

我在Spring Boot应用程序中有以下错误:

SLF4J:类路径包含多个SLF4J绑定。SLF4J:在[jar:file:/opt/tomcat/webapps/ROOT/WEB-

INF/lib/slf4j-simple-1.7.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]中找到绑定在[jar:file:/opt/tomcat/webapps/ROOT/WEB-

INF/lib/logback-

classic-1.1.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]中SLF4J:参见http://

www .slf4j.org /

codes.html#multiple_bindings进行解释。

我去了链接,并尝试从我认为要导入的pom中删除slf4j-simple-1.7.13和logback-classic,但它没有用。

    <dependency>

<groupId>org.apache.solr</groupId>

<artifactId>solr-solrj</artifactId>

<version>${solrj.version}</version>

<exclusions>

<exclusion>

<groupId>org.slf4j</groupId>

<artifactId>slf4j-api</artifactId>

</exclusion>

</exclusions>

</dependency>

    <dependency>

<groupId>org.apache.solr</groupId>

<artifactId>solr-solrj</artifactId>

<version>${solrj.version}</version>

<exclusions>

<exclusion>

<groupId>ch.qos.logback</groupId>

<artifactId>logback-classic</artifactId>

</exclusion>

</exclusions>

</dependency>

Solr J版本:

    <solrj.version>5.2.1</solrj.version>

如何确定这是正确的违规模块?我做错了什么吗?

pom文件使用我们自己创建的spring boot父级。也许这是需要进行排除的地方?

这是org.slf4j的依赖关系树:

[INFO] 

[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ some-service ---

[INFO] com.company.io.some.service:some-service:war:1.0.0-SNAPSHOT

[INFO] +- com.company.io.commons:commons-mongo:jar:1.0.0:compile

[INFO] | \- com.company.io.commons:discovery-schema:jar:1.0.0:compile

[INFO] | +- com.company.io.commons:commons-schema:jar:1.0.0:compile

[INFO] | | \- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.6; omitted for duplicate)

[INFO] | +- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.7; omitted for duplicate)

[INFO] | +- ch.qos.logback:logback-classic:jar:1.1.3:compile

[INFO] | | \- (org.com.company.io:slf4j-api:jar:1.7.13:compile - version managed from 1.7.7; omitted for duplicate)

[INFO] | \- com.company.io.commons:commons-utils:jar:1.0.0:compile

[INFO] | \- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.6; omitted for duplicate)

[INFO] +- org.apache.solr:solr-solrj:jar:5.2.1:compile

[INFO] | \- org.slf4j:slf4j-api:jar:1.7.13:compile

[INFO] +- de.flapdoodle.embed:de.flapdoodle.embed.mongo:jar:1.50.5:test

[INFO] | \- de.flapdoodle.embed:de.flapdoodle.embed.process:jar:1.50.2:test

[INFO] | \- (org.slf4j:slf4j-api:jar:1.7.13:test - version managed from 1.7.10; omitted for duplicate)

[INFO] +- org.springframework.boot:spring-boot-starter-actuator:jar:1.3.0.RELEASE:compile

[INFO] | \- org.springframework.boot:spring-boot-starter:jar:1.3.0.RELEASE:compile

[INFO] | \- org.springframework.boot:spring-boot-starter-logging:jar:1.3.0.RELEASE:compile

[INFO] | +- org.slf4j:jcl-over-slf4j:jar:1.7.13:compile

[INFO] | | \- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.10; omitted for duplicate)

[INFO] | +- org.slf4j:jul-to-slf4j:jar:1.7.13:compile

[INFO] | | \- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.10; omitted for duplicate)

[INFO] | \- org.slf4j:log4j-over-slf4j:jar:1.7.13:compile

[INFO] | \- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.10; omitted for duplicate)

[INFO] +- com.company.io.spring.boot.starter:central-config-spring-boot-starter:jar:1.0.0:compile

[INFO] | +- com.company.io.config:config-client:jar:1.0.0:compile

[INFO] | | \- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.12; omitted for duplicate)

[INFO] | +- io.springfox:springfox-swagger-ui:jar:2.2.2:compile

[INFO] | | \- io.springfox:springfox-spring-web:jar:2.2.2:compile

[INFO] | | \- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.12; omitted for duplicate)

[INFO] | \- io.springfox:springfox-swagger2:jar:2.2.2:compile

[INFO] | +- io.swagger:swagger-models:jar:1.5.3:compile

[INFO] | | \- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.6.3; omitted for duplicate)

[INFO] | +- io.springfox:springfox-spi:jar:2.2.2:compile

[INFO] | | \- io.springfox:springfox-core:jar:2.2.2:compile

[INFO] | | \- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.12; omitted for duplicate)

[INFO] | +- io.springfox:springfox-swagger-common:jar:2.2.2:compile

[INFO] | | \- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.12; omitted for duplicate)

[INFO] | +- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.12; omitted for duplicate)

[INFO] | +- org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile

[INFO] | | \- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.10; omitted for duplicate)

[INFO] | +- org.springframework.plugin:spring-plugin-metadata:jar:1.2.0.RELEASE:compile

[INFO] | | \- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.10; omitted for duplicate)

[INFO] | \- org.springframework.hateoas:spring-hateoas:jar:0.19.0.RELEASE:compile

[INFO] | \- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.12; omitted for duplicate)

[INFO] +- com.company.io.spring.boot.starter:ana-spring-boot-starter:jar:1.0.0:compile

[INFO] | \- com.company.io.auth:ana-client:jar:1.2.0:compile

[INFO] | +- com.company.io.commons:commons-jersey:jar:1.0.0:compile

[INFO] | | \- com.company.io.commons:rules-schema:jar:1.0.0:compile

[INFO] | | +- com.company.io.commons:event-schema:jar:1.0.0:compile

[INFO] | | | +- com.company.io.commons:data-schema:jar:1.0.0:compile

[INFO] | | | | \- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.6; omitted for duplicate)

[INFO] | | | \- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.6; omitted for duplicate)

[INFO] | | +- com.company.io.commons:notification-schema:jar:1.0.0:compile

[INFO] | | | \- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.6; omitted for duplicate)

[INFO] | | \- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.6; omitted for duplicate)

[INFO] | +- com.company.io.commons:commons-statsd:jar:1.0.0:compile

[INFO] | | +- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.12; omitted for duplicate)

[INFO] | | \- org.slf4j:slf4j-simple:jar:1.7.13:compile (version managed from 1.7.12)

[INFO] | | \- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.12; omitted for duplicate)

[INFO] | \- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.7; omitted for duplicate)

[INFO] \- io.company.on.spring.boot.starter:metrics-spring-boot-starter:jar:1.0.0:compile

[INFO] +- io.dropwizard.metrics:metrics-core:jar:3.1.2:compile

[INFO] | \- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.7; omitted for duplicate)

[INFO] +- io.dropwizard.metrics:metrics-annotation:jar:3.1.2:compile

[INFO] | \- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.7; omitted for duplicate)

[INFO] +- io.dropwizard.metrics:metrics-healthchecks:jar:3.1.2:compile

[INFO] | \- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.7; omitted for duplicate)

[INFO] +- io.dropwizard.metrics:metrics-json:jar:3.1.2:compile

[INFO] | \- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.7; omitted for duplicate)

[INFO] +- io.dropwizard.metrics:metrics-jvm:jar:3.1.2:compile

[INFO] | \- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.7; omitted for duplicate)

[INFO] +- io.dropwizard.metrics:metrics-servlet:jar:3.1.2:compile

[INFO] | \- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.7; omitted for duplicate)

[INFO] +- io.dropwizard.metrics:metrics-servlets:jar:3.1.2:compile

[INFO] | \- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.7; omitted for duplicate)

[INFO] \- com.ryantenney.metrics:metrics-spring:jar:3.0.4:compile

[INFO] \- (org.slf4j:slf4j-api:jar:1.7.13:compile - version managed from 1.7.5; omitted for duplicate)

回答:

您是否尝试过org.slf4j:slf4j-simple在POM中添加排除项,例如:

<dependency>

<groupId>com.company.io.spring.boot.starter</groupId>

<artifactId>ana-spring-boot-starter</artifactId>

<version>1.0.0</version>

<exclusions>

<exclusion>

<groupId>org.slf4j</groupId>

<artifactId>slf4j-simple</artifactId>

</exclusion>

</exclusions>

</dependency>

以上是 SLF4J的多个绑定 的全部内容, 来源链接: utcz.com/qa/411931.html

回到顶部