MVN package 时 SLF4J: Class path contains multiple SLF4J bindings 错误解决办法

编译通过,打包时报如下错误 :

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/Administrator/.m2/repository/ch/qos/logback/logback-classic/1.1.7/logback-classic-1.1.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/Administrator/.m2/repository/org/slf4j/slf4j-log4j12/1.7.21/slf4j-log4j12-1.7.21.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]

先把工程的pom.xml里面对org.slf4j的依赖注释掉,然后重新打包

<dependency>
   <groupId>org.slf4j</groupId>
   <artifactId>slf4j-log4j12</artifactId>
   <version>1.7.21</version>
   <scope>test</scope>
</dependency>-->

如果还是报错, 则在工程目录下用     mvn dependency:tree -P profile > dep.txt  把工程的依赖关系导出为文件,

在文件中查找对slf4J和log4j库的依赖关系,把它排除掉不打包即可。

<exclusions>
   <exclusion>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-logging</artifactId>
   </exclusion>
   <exclusion>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
   </exclusion>
   <exclusion>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
   </exclusion>
</exclusions>




猜你喜欢

转载自blog.csdn.net/langeldep/article/details/79638590