Man*_*ddy 2 maven-2 log4j classpath slf4j maven
尝试进行MAVEN INSTALL时出现此错误。我尝试排除,但不确定pom文件中的位置。让我在pom文件中应如何以及应使用哪些排除标签。我还将我的pom文件片段附加在其中,以包括排除项SLF4J:类路径包含多个SLF4J绑定。
SLF4J:在[jar:file:/ C:/Users/147188/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/ org / slf4j / impl / StaticLoggerBinder.class]
SLF4J:在[jar:file:/ C:/Users/147188/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.10.0/log4j-slf4j-impl-2.10.0中找到绑定.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J:有关说明,请参见http://www.slf4j.org/codes.html#multiple_bindings。SLF4J:实际绑定的类型为[ch.qos.logback.classic.util.ContextSelectorStaticBinder]
POM文件:
<!-- Start of required part to make log4j work -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- End of required part to make log4j work -->
Run Code Online (Sandbox Code Playgroud)
1次
mvn dependency:tree
Run Code Online (Sandbox Code Playgroud)
查看哪个包导入org.slf4j
2保留一个,排除另一个
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
Run Code Online (Sandbox Code Playgroud)
排除默认日志记录的正确方法,并配置 log4j 进行日志记录。在 Spring Boot 项目中添加这个依赖项,如果它还没有的话
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5713 次 |
最近记录: |