问题描述
启动 web 应用时,每次都报下面的警告信息:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/apache-maven-3.3.9/Repositories/repository/org/slf4j/slf4j-log4j12/1.7.5/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/apache-maven-3.3.9/Repositories/repository/ch/qos/logback/logback-classic/1.0.13/logback-classic-1.0.13.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 (cn.gs.proj.vms.support.DefaultVmClientSessionListener).
log4j:WARN Please initialize the log4j system properly.
从打印的信息看是类路径下包含多个 SLF4J 绑定,是 slf4j-log4j12-1.7.5.jar 和
logback-classic-1.0.13.jar,而 logback-classic-1.0.13.jar 里面有包含 slf4j-api,导致类路径下包含多个 SLF4J 绑定。
解决方法
只要去掉 slf4j-log4j12 依赖就可以了:
<!-- <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency> -->