maven中SLF4J:Failedtoloadclass“org.slf4j.impl.StaticLoggerBinder的错误怎么解决

这篇文章主要介绍“maven中SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder的错误怎么解决”,在日常操作中,相信很多人在maven中SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder的错误怎么解决问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”maven中SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder的错误怎么解决”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

创新互联公司专注于乌苏网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供乌苏营销型网站建设,乌苏网站制作、乌苏网页设计、乌苏网站官网定制、小程序定制开发服务,打造乌苏网络公司原创品牌,更为您提供乌苏网站排名全网营销落地服务。

SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder

最近写新项目用maven引入sl4j总是提示这个错误,查了一下一些是因为引入的包冲突。比如:https://www.jianshu.com/p/b562b7ff499f

这里写的比较详细:

slf4j-log4j12.jar (for log4j logging),
slf4j-jdk14.jar (for Java logging),
slf4j-jcl.jar (if you’re using Commons logging)
logback-classic.jar (for logback logging).

以上的包引入一种即可

我的一开始以为是包冲突,然后通过依赖树命令发现是一个低级错误,引入的sl4j包的scope是test级别的,然后运行就出错了。直接去掉即可,不写<scope>标签默认compile级别。

D:\work\eclipse8\abc\share>mvn dependency:tree
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------------< xgame:sharing >----------------------------
[INFO] Building sharing 0.0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ sharing ---
[INFO] xgame:sharing:jar:0.0.1
[INFO] +- io.netty:netty-all:jar:4.1.38.Final:compile
[INFO] +- commons-lang:commons-lang:jar:2.6:compile
[INFO] +- org.mybatis:mybatis:jar:3.2.7:compile
[INFO] +- com.google.protobuf:protobuf-java:jar:2.5.0:compile
[INFO] +- com.google.guava:guava:jar:19.0:compile
[INFO] +- commons-codec:commons-codec:jar:1.13:compile
[INFO] +- commons-beanutils:commons-beanutils:jar:1.8.3:compile
[INFO] |  \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- com.lmax:disruptor:jar:3.3.7:compile
[INFO] +- org.quartz-scheduler:quartz:jar:2.2.3:compile
[INFO] |  +- c3p0:c3p0:jar:0.9.1.1:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.7.7:compile
[INFO] +- net.sf.json-lib:json-lib:jar:jdk15:2.4:compile
[INFO] |  +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO] |  \- net.sf.ezmorph:ezmorph:jar:1.0.6:compile
[INFO] +- com.typesafe:config:jar:1.3.4:compile
[INFO] +- MySQL:mysql-connector-java:jar:5.1.8:compile
[INFO] \- org.slf4j:slf4j-log4j12:jar:1.7.26:test
[INFO]    \- log4j:log4j:jar:1.2.17:test
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.907 s
[INFO] Finished at: 2019-08-16T00:21:52+08:00
[INFO] ------------------------------------------------------------------------

查maven依赖版本的时候,默认带了scope为test。

<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>1.7.26</version>
    <scope>test</scope>
</dependency>

到此,关于“maven中SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder的错误怎么解决”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注创新互联网站,小编会继续努力为大家带来更多实用的文章!

网站标题:maven中SLF4J:Failedtoloadclass“org.slf4j.impl.StaticLoggerBinder的错误怎么解决
分享URL:https://www.cdcxhl.com/article30/gihiso.html

成都网站建设公司_创新互联,为您提供定制开发网站排名响应式网站网站收录小程序开发建站公司

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

小程序开发