我不但有代碼潔癖,而且還有日誌潔癖。html
看着這樣的代碼就會感到不舒服:web
if(a==0 )
必須把它改爲:spring
if (a == 0)
才能繼續思考。apache
當我在Tomcat
輸出的日誌裏看到這樣的警告:app
SLF4J: Class path contains multiple SLF4J bindings
不由陷入了深深的思考。webapp
我討厭一切警告。this
Treat warnings as errors or delete them, but never spend human labor looking through warning lists routinely.
將警告當錯誤同樣對待,或者完全刪除相關代碼,可是絕對不要浪費時間天天對它視若無睹。
因而,像大家同樣開始在網上搜索。.net
有人說這樣解決。日誌
有人說那樣解決。code
還有人說Solve it this way.
可是我告訴大家,沒有一個方法能解決。
個人pom.xml
文件是這麼寫的:
<dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.7</version> </dependency> <dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-all</artifactId> <version>5.11.1</version> </dependency>
這是由於activemq-all.jar
包是一個ueber
包,它裏面已經包含了一個slf4j-log4j12.jar
,你妄圖用這樣的方法去解決這個警告:
<dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-all</artifactId> <version>5.11.1</version> <exclusions> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </exclusion> </exclusions> </dependency>
是註定不可能成功的。
在這裏,最正確地解決這個問題的方法是:
<dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-all</artifactId> <version>5.11.1</version> </dependency>
把activemq-all
改爲activemq-spring
就行了。
雖然如此,我又遇到了問題:
SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/C:/Users/admin/.m2/repository/org/slf4j/slf4j-log4j12/1.7.7/slf4j-log4j12-1.7.7.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/C:/Users/admin/.m2/repository/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
此次pom.xml
是沒有任何問題的,但爲何還有這個錯誤呢?
最後發現竟然是有人在/src/main/webapp/WEB-INF
下放了一個lib
文件夾,在這個文件夾裏放了一個老版本的slf4j-log4j12-1.6.1.jar
進去。
果斷刪除全部lib
文件夾下的文件。
從新提交代碼,編譯,部署。
終於,咱們完全解決了全部SLF4J: Class path contains multiple SLF4J bindings.
問題。
日誌一片清爽。
感受世界從新恢復了秩序。