activemq-all强制我使用log4j slf4j实现

时间:2014-07-15 10:25:34

标签: maven log4j activemq slf4j logback

我想在我的应用程序中使用logback slf4j实现,但activemq-all通过包含log4j实现类来破坏类路径。我不是唯一一个面临这个问题的人,例如multiple SLF4J bindings Error with activemq-all-5.6.0.jar所见证的那样。根据那篇文章,我必须用

替换activemq-all
org.apache.activemq:activemq-camel
org.apache.activemq:activemq-core
org.apache.activemq:activemq-console
org.apache.activemq:activemq-jaas
org.apache.activemq:activemq-optional
org.apache.activemq:kahadb
org.apache.geronimo.specs:geronimo-jms_1.1_spec
org.apache.geronimo.specs:geronimo-jta_1.0.1B_spec
org.apache.geronimo.specs:geronimo-j2ee-management_1.1_spec
org.apache.geronimo.specs:geronimo-annotation_1.0_spec.

问题是我没有这些工件的完整maven依赖项(组ID,工件ID,版本)。

可以为某人提供现成的替代品
        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-all</artifactId>
            <version>5.9.0</version>
        </dependency> 

3 个答案:

答案 0 :(得分:3)

您可以使用活动的mq核心库。请注意,活动mq向后兼容客户端。

    <dependency>
        <groupId>org.apache.activemq</groupId>
        <artifactId>activemq-core</artifactId>
        <version>5.4.3</version>
          <exclusions>
            <exclusion>                 
              <artifactId>org.slf4j</artifactId>
              <groupId>slf4j-log4j12</groupId>
            </exclusion>
            <exclusion>                 
              <artifactId>log4j</artifactId>
              <groupId>log4j</groupId>
            </exclusion>
        </exclusions>
    </dependency>

答案 1 :(得分:1)

简而言之,您已经为您找到的工件列出了以冒号分隔的组ID /工件ID 。请注意,它们满足ActiveMQ 5.6的一些用例。例如,activemq-core不再有效 - 请改用activemq-client和activemq-broker。

目前,这些工件捆绑在activemq-all中。但您可能需要查看pom.xml以查找您选择的版本(此列表可能会随时间而变化)。除非您要在应用程序中嵌入包含所有传输,插件和配置的代理,否则您可能不需要所有这些。

<artifactSet>
  <includes>
    <include>${project.groupId}:activemq-client</include>
    <include>${project.groupId}:activemq-openwire-legacy</include>
    <include>${project.groupId}:activemq-camel</include>
    <include>${project.groupId}:activemq-jaas</include>
    <include>${project.groupId}:activemq-broker</include>
    <include>${project.groupId}:activemq-console</include>
    <include>${project.groupId}:activemq-shiro</include>
    <include>${project.groupId}:activemq-spring</include>
    <include>${project.groupId}:activemq-pool</include>
    <include>${project.groupId}:activemq-jms-pool</include>
    <include>${project.groupId}:activemq-amqp</include>
    <include>${project.groupId}:activemq-http</include>
    <include>${project.groupId}:activemq-mqtt</include>
    <include>${project.groupId}:activemq-stomp</include>
    <include>${project.groupId}:activemq-kahadb-store</include>
    <include>${project.groupId}:activemq-leveldb-store</include>
    <include>${project.groupId}:activemq-jdbc-store</include>
    <include>org.apache.activemq.protobuf:activemq-protobuf</include>
    <include>org.fusesource.hawtbuf:hawtbuf</include>
    <include>org.jasypt:jasypt</include>
    <include>org.apache.geronimo.specs:geronimo-jms_1.1_spec</include>
    <include>org.apache.geronimo.specs:geronimo-jta_1.0.1B_spec</include>
    <include>org.apache.geronimo.specs:geronimo-j2ee-management_1.1_spec</include>
    <include>org.apache.geronimo.specs:geronimo-annotation_1.0_spec</include>
    <include>org.slf4j:slf4j-api</include>
    <include>org.slf4j:slf4j-log4j12</include>
    <include>log4j:log4j</include>
  </includes>
</artifactSet>

好的,org.apache.activemq的版本号应该只是您要使用的版本号。对于geronimo规范,这不是那么明显。

<dependency>
   <groupId>org.apache.geronimo.specs</groupId>
   <artifactId>geronimo-jms_1.1_spec</artifactId>
   <version>1.1.1</version>
</dependency>

<dependency>
      <groupId>org.apache.geronimo.specs</groupId>
      <artifactId>geronimo-j2ee-management_1.1_spec</artifactId>
      <version>1.0.1</version>
</dependency>

<dependency>
      <groupId>org.apache.geronimo.specs</groupId>
      <artifactId>geronimo-annotation_1.0_spec</artifactId>
      <version>1.1.1</version>
</dependency>

答案 2 :(得分:0)

我在使用 activemq-all API 时也遇到了同样的问题,我用下面的依赖替换了这个依赖,它对我有用。

<!-- https://mvnrepository.com/artifact/org.apache.activemq/activemq-spring -->
<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-spring</artifactId>
    <version>5.14.3</version>
</dependency>

希望这可以帮助其他人。