springboot启动出现如下警告:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/wangfei/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/wangfei/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.11.2/log4j-slf4j-impl-2.11.2.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]
ide内启动仅仅是警告,打成jar发布到服务器,直接报了个日志类相关的异常,中断启动。
从信息上看是logback-classic 和 log4j-slf4j-impl冲突,通过查找maven的依赖关系,找到引入的包并排除掉log4j-slf4j-impl-2.11.2.jar
<dependency>
<groupId>xxxxxx/groupId>
<artifactId>xxxx</artifactId>
<version>xxxxx</version>
<exclusions>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</exclusion>
</exclusions>
</dependency>