IDEA: Jar 包冲突 (SLF4J:Class path contains multiple SLF4J bindings)

作为新手,今天在idea上运行文件的时候,进程栏里莫名跳出下面字样:

SLF4J: Class path contains multiple SLF4J bindings. 
SLF4J: Found binding in [jar:file:/root/.ivy2/cache/org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class] 
SLF4J: Found binding in [jar:file:/root/.sbt/boot/scala-2.12.7/org.scala-sbt/sbt/1.2.8/log4j-slf4j-impl-2.11.1.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]

奇怪的是,此种情况并不影响文件的执行结果,但却能影响我们对于代码或运行结果的完整性要求,心慌慌呀???

于是乎,我就和它较劲儿啦。。。控制不住内心的好奇和求胜欲,就在网页中寻求各位大神的杰作。了解到,这原来是Jar 包冲突造成的,那么解决方案就是删除相应的jar包不让它冲突。

但发现很多人都在玩 Maven,所以一般都是通过配置它的 pom.xml 文件来解决,但我用的是 Scala(sbt),所以刚开始很苦恼:

Where is the JAR package ? How to find it ?

终于,在一位叫 @锐湃 的大神那里找到了路子。

原来文件路径就藏在我的问题里

SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/root/.ivy2/cache/org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]

SLF4J: Found binding in [jar:file:/root/.sbt/boot/scala-2.12.7/org.scala-sbt/sbt/1.2.8/log4j-slf4j-impl-2.11.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]

那么, 就可以通过终端来消灭它了(删除其中的一个)

[root@idea081 ~]# cd  .sbt/boot/scala-2.12.7/org.scala-sbt/sbt/1.2.8/

[root@idea081 1.2.8]#ls

发现目标文件,于是乎

[root@idea081 1.2.8]# rm -rf log4j-slf4j-impl-2.11.1.jar

OK,再运行,问题解决。

当然,也可以通过下面删除另一个:

[root@idea081 ~]# rm -rf .ivy2/cache/org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.7.10.jar

--------------------------------------------------------------------------------------------------------------------------------------------------

就喜欢这种遇到问题,然后通过一番搜索和思考后把它完美解决的痛快感,感觉到“浪费时间”的价值,哈哈哈

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值