每当我运行一个多模块Maven项目时,都会出现以下错误:
Exception in thread "main" java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation
我尝试了几种不同的方法将其删除,但没有任何效果。 例如:
1)Resolve multiple SLF4J bindings in maven project
2)Spring Boot: multiple SLF4J bindings
3)https://dzone.com/articles/solving-dependency-conflicts-in-maven
但是上述解决方案都不适合我。
这是模块的pom.xml:
<dependencies>
<dependency>
<groupId>com.mydomain</groupId>
<artifactId>commons-module</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.littleshoot</groupId>
<artifactId>proxy</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
这是模块的依赖关系树:
com.mydomain:circuit-module:jar:1.0-SNAPSHOT
[INFO] +- com.mydomain:commons-module:jar:1.0-SNAPSHOT:compile
[INFO] | +- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] | +- org.postgresql:postgresql:jar:42.2.1:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-data-jpa:jar:2.0.0.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-aop:jar:2.0.0.RELEASE:compile
[INFO] | | | \- org.aspectj:aspectjweaver:jar:1.8.13:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.0.0.RELEASE:compile
[INFO] | | | +- com.zaxxer:HikariCP:jar:2.7.8:compile
[INFO] | | | \- org.springframework:spring-jdbc:jar:5.0.4.RELEASE:compile
[INFO] | | +- org.hibernate:hibernate-core:jar:5.2.14.Final:compile
[INFO] | | | +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
[INFO] | | | +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] | | | +- org.javassist:javassist:jar:3.22.0-GA:compile
[INFO] | | | +- antlr:antlr:jar:2.7.7:compile
[INFO] | | | +- org.jboss:jandex:jar:2.0.3.Final:compile
[INFO] | | | +- com.fasterxml:classmate:jar:1.3.4:compile
[INFO] | | | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | | | \- org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile
[INFO] | | +- javax.transaction:javax.transaction-api:jar:1.2:compile
[INFO] | | +- org.springframework.data:spring-data-jpa:jar:2.0.5.RELEASE:compile
[INFO] | | | +- org.springframework.data:spring-data-commons:jar:2.0.5.RELEASE:compile
[INFO] | | | +- org.springframework:spring-orm:jar:5.0.4.RELEASE:compile
[INFO] | | | \- org.springframework:spring-tx:jar:5.0.4.RELEASE:compile
[INFO] | | \- org.springframework:spring-aspects:jar:5.0.4.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-mail:jar:2.0.0.RELEASE:compile
[INFO] | | \- com.sun.mail:javax.mail:jar:1.6.1:compile
[INFO] | | \- javax.activation:activation:jar:1.1:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-freemarker:jar:2.0.0.RELEASE:compile
[INFO] | | \- org.freemarker:freemarker:jar:2.3.27-incubating:compile
[INFO] | +- commons-validator:commons-validator:jar:1.6:compile
[INFO] | | +- commons-beanutils:commons-beanutils:jar:1.9.2:compile
[INFO] | | +- commons-digester:commons-digester:jar:1.8.1:compile
[INFO] | | +- commons-logging:commons-logging:jar:1.2:compile
[INFO] | | \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-amqp:jar:2.0.0.RELEASE:compile
[INFO] | | +- org.springframework:spring-messaging:jar:5.0.4.RELEASE:compile
[INFO] | | \- org.springframework.amqp:spring-rabbit:jar:2.0.2.RELEASE:compile
[INFO] | | +- org.springframework.amqp:spring-amqp:jar:2.0.2.RELEASE:compile
[INFO] | | +- com.rabbitmq:amqp-client:jar:5.1.2:compile
[INFO] | | +- com.rabbitmq:http-client:jar:1.3.1.RELEASE:compile
[INFO] | | +- org.springframework:spring-web:jar:5.0.4.RELEASE:compile
[INFO] | | \- org.springframework.retry:spring-retry:jar:1.2.2.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-data-redis:jar:2.0.0.RELEASE:compile
[INFO] | | \- org.springframework.data:spring-data-redis:jar:2.0.5.RELEASE:compile
[INFO] | | +- org.springframework.data:spring-data-keyvalue:jar:2.0.5.RELEASE:compile
[INFO] | | \- org.springframework:spring-oxm:jar:5.0.4.RELEASE:compile
[INFO] | \- redis.clients:jedis:jar:2.9.0:compile
[INFO] | \- org.apache.commons:commons-pool2:jar:2.5.0:compile
[INFO] +- org.littleshoot:proxy:jar:1.0:compile
[INFO] +- org.springframework.boot:spring-boot-starter-cache:jar:2.0.0.RELEASE:compile
[INFO] | +- org.springframework:spring-context:jar:5.0.4.RELEASE:compile
[INFO] | | +- org.springframework:spring-aop:jar:5.0.4.RELEASE:compile
[INFO] | | +- org.springframework:spring-beans:jar:5.0.4.RELEASE:compile
[INFO] | | \- org.springframework:spring-expression:jar:5.0.4.RELEASE:compile
[INFO] | \- org.springframework:spring-context-support:jar:5.0.4.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.0.0.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test:jar:2.0.0.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.0.0.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] | | | \- org.ow2.asm:asm:jar:5.0.4:test
[INFO] | | \- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] | +- junit:junit:jar:4.12:test
[INFO] | +- org.assertj:assertj-core:jar:3.9.1:test
[INFO] | +- org.mockito:mockito-core:jar:2.15.0:test
[INFO] | | +- net.bytebuddy:byte-buddy:jar:1.7.10:test
[INFO] | | +- net.bytebuddy:byte-buddy-agent:jar:1.7.10: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.0.4.RELEASE:compile
[INFO] | | \- org.springframework:spring-jcl:jar:5.0.4.RELEASE:compile
[INFO] | +- org.springframework:spring-test:jar:5.0.4.RELEASE:test
[INFO] | \- org.xmlunit:xmlunit-core:jar:2.5.1:test
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.5.5:test
[INFO] | +- org.apache.httpcomponents:httpcore:jar:4.4.9:test
[INFO] | \- commons-codec:commons-codec:jar:1.11:test
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.4:test
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:test
[INFO] | \- com.fasterxml.jackson.core:jackson-core:jar:2.9.4:test
[INFO] +- org.springframework.boot:spring-boot-starter:jar:2.0.0.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot:jar:2.0.0.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.0.0.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-logging:jar:2.0.0.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.apache.logging.log4j:log4j-to-slf4j:jar:2.10.0:compile
[INFO] | | | \- org.apache.logging.log4j:log4j-api:jar:2.10.0:compile
[INFO] | | \- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
[INFO] | +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] | \- org.yaml:snakeyaml:jar:1.19:runtime
[INFO] +- commons-lang:commons-lang:jar:2.6:compile
[INFO] \- org.projectlombok:lombok:jar:1.16.20:provided
我应该在哪里将标记与要排除的模块放在一起,以便它起作用?
答案 0 :(得分:0)
您可能想要从启动启动器中排除日志,但是随后您可能需要为特定的日志框架添加依赖项。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<!-- Exclude Spring Boot logging -->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
以类似方式排除或退出spring-boot-starter-logging
的登录