当你启动service或者web项目的时候,出现了如下详细地异常,那说明你配置的log4j与logback jar包发生了冲突:
<span style="color:#ff0000">SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/G:/m2/repository/org/slf4j/slf4j-log4j12/1.7.22/slf4j-log4j12-1.7.22.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/G:/m2/repository/ch/qos/logback/logback-classic/1.1.8/logback-classic-1.1.8.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 [org.slf4j.impl.Log4jLoggerFactory]
log4j:WARN No appenders could be found for logger (org.springframework.core.env.StandardEnvironment).
log4j:WARN Please initialize the log4j system properly.</span>
就比如,我的web项目用logback日志,通过查看jar包依赖列表,并没有发现有log4j的踪影。但是,一定要注意,项目依赖的任何jar,有可能你本身的项目没引用,像我引用了公共的jar,说不定里面就包含了log4j导致了冲突,我的就是这样。
双击展开引用,问题的根源找到了。
我在jar包引用的地方,屏蔽log4j。
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>