【问题标题】:activemq-all forces me to use log4j slf4j implementationactivemq-all 强制我使用 log4j slf4j 实现
【发布时间】:2014-09-05 12:07:40
【问题描述】:

我想在我的应用程序中使用 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> 

【问题讨论】:

    标签: maven log4j activemq slf4j logback


    【解决方案1】:

    您可以使用活跃的 mq 核心库。请注意,active 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>
    

    【讨论】:

    • 你的意思是 artifactid 和 groupid 反过来吗? ` slf4j-log4j12org.slf4j` 如here
    【解决方案2】:

    简而言之,您已经列出了您找到的工件的组 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>
    

    【讨论】:

      【解决方案3】:

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

      希望这可以帮助其他人。

      【讨论】:

        猜你喜欢
        • 2022-01-25
        • 2023-04-09
        • 1970-01-01
        • 1970-01-01
        • 2012-07-31
        • 1970-01-01
        • 1970-01-01
        • 2023-03-21
        • 1970-01-01
        相关资源
        最近更新 更多