我在Spring启动应用程序中遇到以下错误:
SLF4J:类路径包含多个SLF4J绑定。 SLF4J:在[jar:file:/opt/tomcat/webapps/ROOT/WEB-INF/lib/slf4j-simple-1.7.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]中找到绑定 SLF4J:在[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 parent。也许这就是需要排除的地方?
这是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)
答案 0 :(得分:0)
您是否尝试在POM中添加org.slf4j:slf4j-simple
排除项,例如:
<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>