作为新手,今天在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
--------------------------------------------------------------------------------------------------------------------------------------------------
就喜欢这种遇到问题,然后通过一番搜索和思考后把它完美解决的痛快感,感觉到“浪费时间”的价值,哈哈哈