如何从activemq-all maven依赖项中排除包含StaticLoggerBinder的jar?

时间:2014-09-04 19:24:06

标签: java maven logging apache-camel slf4j

我正在使用ActiveMQ(一个apache camel组件)将短信从网络发送到GSM手机,所以我需要使用SLF4J。 当我运行它时,我在netbeans项目的输出中得到了这个 看起来这个jar存在两次,我认为我需要在我的pom.xml中添加一个排除依赖项,但我不知道该怎么做!

这是我pom.xml中的SLF4的一部分:

<!-- 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]

3 个答案:

答案 0 :(得分:4)

尝试以下方法:

<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-all</artifactId>
    <version>5.9.0</version>
    <type>pom</type>
</dependency>

[AMQ-5009] Switch activemq-all from shaded jar to pom dependency aggregator - ASF JIRA中查看更多内容。

答案 1 :(得分:3)

你的问题是缺少一些上下文,但是我说你应该简单地从你的POM中删除slf4j-log4j12依赖关系,因为无论如何SLF4J绑定嵌入activemq-all-5.9.0.jar

或许您可以尝试不将activemq-all与嵌入式依赖项一起使用,并将单个ActiveMQ工件与普通的传递依赖项一起使用。

答案 2 :(得分:2)

我同意不使用activemq-all,而是使用您需要的各个依赖项。一般来说,我发现使用&#39; -all&#39;依赖关系可能会产生问题。通常,这些重新打包其他依赖关系,其中正常的Maven依赖关系解析过程无法获得它们。然后,如果您需要使用嵌入式依赖项的更高版本,则会导致问题,并且跟踪是非常棘手/耗时的。

(根据@bmargulies请求将此评论作为答案。)

相关问题