【问题标题】:http-client excluded from spring-rabbithttp-client 从 spring-rabbit 中排除
【发布时间】:2018-06-19 14:45:21
【问题描述】:

我在 Spring Boot 1.5.6.RELEASE 中使用 http-clientspring-rabbit,它工作正常。

Spring Boot 2.0.2.RELEASE 中,http-client 被排除在 spring-rabbit pom.xml 之外。

我不想手动添加http-client 并跟踪启动版本之间的版本。

spring-boot-starter-amqp-1.5.6.RELEASE:

<dependency>
    <groupId>org.springframework.amqp</groupId>
    <artifactId>spring-rabbit</artifactId>
</dependency>

spring-boot-starter-amqp-2.0.2.RELEASE:

<dependency>
  <groupId>org.springframework.amqp</groupId>
  <artifactId>spring-rabbit</artifactId>
  <version>2.0.3.RELEASE</version>
  <scope>compile</scope>
  <exclusions>
    <exclusion>
      <artifactId>http-client</artifactId>
      <groupId>com.rabbitmq</groupId>
    </exclusion>
  </exclusions>
</dependency>

为什么http-client 被排除在外,我可以在不定义版本的情况下包含它吗?版本是2.0.1.RELEASE,但它没有被提取为spring-rabbit 中的属性。

【问题讨论】:

  • 我认为被&lt;dependency&gt; &lt;groupId&gt;com.rabbitmq&lt;/groupId&gt; &lt;artifactId&gt;amqp-client&lt;/artifactId&gt; &lt;version&gt;5.1.2&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt;取代
  • amqp-client 不一样。我正在使用org.springframework.amqp.rabbit.core.RabbitManagementTemplate,它依赖于com.rabbitmq.http.client.Client,所以我需要http-client

标签: java spring maven spring-boot rabbitmq


【解决方案1】:

根据 Spring AMQP 文档,依赖关系 com.rabbitmq:http-client 现在是可选的。显然,这已更改为允许多个客户端实现。

启用管理插件后,RabbitMQ 服务器会暴露一个 用于监控和配置代理的 REST API。一个 Java 绑定 现在提供 API。 com.rabbitmq.http.client.Client 是一个 标准的、即时的,因此是阻塞的 API。它基于 Spring Web 模块及其 RestTemplate 实现。在另一 手, com.rabbitmq.http.client.ReactorNettyClient 是反应式的, 基于 Reactor Netty 项目的非阻塞实现。

跃点依赖(com.rabbitmq:http-client)现在也是可选的。

  • 客户端:即时和阻塞客户端
  • ReactorNettyClient:反应式非阻塞客户端

See the documentation

如果你想使用标准的 http-client,你可以添加依赖。请注意,您不需要自己跟踪正确的版本。该版本是根据您的spring-boot-starter-amqp 版本自动选择的。

// Maven
<dependency>
  <groupId>com.rabbitmq</groupId>
  <artifactId>http-client</artifactId>
</dependency>

// Gradle
compile("com.rabbitmq:http-client")

如何启用特定客户端也可以参考相关的GitHub项目:rabbitmq/hop

【讨论】:

  • 很抱歉。就我而言,我注意到以下内容。在自定义库中定义 RabbitMQ 依赖项时,自动版本对我有用,包括该库和我的应用程序中的 http-client 依赖项。当我将 http-client 依赖项移动到库时,我需要手动设置版本。目前添加了com.rabbitmq:http-client=2.0.1.RELEASEio.projectreactor.ipc:reactor-netty=0.7.1.RELEASE
猜你喜欢
  • 1970-01-01
  • 2015-04-16
  • 1970-01-01
  • 1970-01-01
  • 2018-02-16
  • 2016-03-16
  • 1970-01-01
  • 1970-01-01
  • 2022-01-08
相关资源
最近更新 更多