我使用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