【问题标题】:How to exclude jar that contains StaticLoggerBinder from activemq-all maven dependency?如何从activemq-all maven依赖项中排除包含StaticLoggerBinder的jar?
【发布时间】:2014-10-29 16:17:01
【问题描述】:

我正在使用 ActiveMQ(一个 apache camel 组件)将 SMS 从 web 发送到 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]

【问题讨论】:

    标签: java maven logging apache-camel slf4j


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      尝试以下方法:

      <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 中查看更多信息。

      【讨论】:

        【解决方案3】:

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

        或者,也许您可​​以尝试不使用带有嵌入式依赖项的 activemq-all,而是使用带有普通传递依赖项的单个 ActiveMQ 工件。

        【讨论】:

        • 我同意不使用activemq-all,而是使用您需要的各个依赖项。一般来说,我发现使用“-all”依赖项会产生问题。通常,这些重新打包其他依赖项,而普通的 Maven 依赖项解析过程无法获得它们。然后,如果您需要使用更高版本的嵌入式依赖项,则会出现问题,并且跟踪起来很棘手/耗时。
        • 这取决于 amq 我们是故意声称控制整个 SLF4J 基础设施,还是错误地合并了一个 slf4j 后端。
        • @user944849 请回答。
        猜你喜欢
        • 1970-01-01
        • 2016-04-29
        • 2015-09-23
        • 2013-05-04
        • 2017-02-01
        • 1970-01-01
        • 2015-06-27
        • 2017-07-11
        • 1970-01-01
        相关资源
        最近更新 更多