启动时warning:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/xcv/Documents/maven/MavenRepository/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:/Users/xcv/Documents/maven/MavenRepository/org/slf4j/slf4j-log4j12/1.7.29/slf4j-log4j12-1.7.29.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]
意思是SLF4J在logback包和slf4j-log4j12包下都有,springboot使用的是logback,所以把slf4j-log4j12排除即可。
1 执行:
mvn dependency:tree
看到maven依赖树,查询slf4j-log4j12
[INFO] | | +- org.apache.zookeeper:zookeeper:jar:3.4.6:compile
[INFO] | | | +- org.slf4j:slf4j-log4j12:jar:1.7.29:compile
[INFO] | | | +- jline:jline:jar:0.9.94:compile
[INFO] | | | \- io.netty:netty:jar:3.7.0.Final:compile
[INFO] | | \- org.jruby.joni:joni:jar:2.1.2:compile
2 添加exclude配置
<exclusions> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </exclusion> </exclusions>
3 启动不再飘红