我使用ActiveMQ(apache camel組件)從網絡發送短信到GSM移動,所以我需要使用SLF4J。 當我運行它時,我在netbeans項目的輸出中得到了這個結果 它看起來像jar是兩次出現的,我認爲我需要在我的pom.xml的依賴項中添加一個排除項,但我不知道該怎麼做做到!如何從activemq-all maven dependency中排除包含StaticLoggerBinder的jar?
這是SLF4在我pom.xml
部分:
<!-- logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.5</version>
<!-- <exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions> -->
</dependency>
這是我的輸出,同時運行我的項目
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/asus/.m2/repository/org/apache/activemq/activemq-all/5.9.0/activemq-all-5.9.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/asus/.m2/repository/org/slf4j/slf4j-log4j12/1.7.5/slf4j-log4j12-1.7.5.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]
我同意不使用ActiveMQ的一切,而不是使用您需要的個體的依賴。一般來說,我發現使用'-all'依賴可能會產生問題。通常,這些重新打包其他依賴項,其中正常的Maven依賴項解析過程無法獲取它們。然後,如果您需要使用更高版本的嵌入式依賴關係,則會產生問題,並且追蹤時會很棘手/耗時。 – user944849 2014-09-05 13:07:08
這取決於我們是否有意要求控制整個SLF4J基礎架構,或者是否錯誤地併入了slf4j後端。 – bmargulies 2014-09-07 16:46:43
@ user944849請做出答案。 – bmargulies 2014-09-07 16:47:11