在引入百度sdk依赖后,项目启动会出现一堆报警信息如下:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/GOLDON/.m2/repository/ch/qos/logback/logback-classic/1.2.11/logback-classic-1.2.11.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/GOLDON/.m2/repository/org/slf4j/slf4j-reload4j/1.7.36/slf4j-reload4j-1.7.36.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]
根据日志信息可以清晰的看出StaticLoggerBinder类冲突,排查原来是百度SDK自带了slf4j的依赖项:
那我们只要排除掉这个依赖就可以解决问题了!
点进报警信息里面的链接SLF4J Error Codes,原来slf4j早已给出了解决方法:
<dependency>
<groupId>com.baidubce</groupId>
<artifactId>bce-java-sdk</artifactId>
<version>0.10.216</version>
<!-- 清除百度sdk自带slf4j依赖项 解决日志冲突问题-->
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
日志又恢复清爽了