使用 com.rabbitmq.http.client.Client 从 Java 向 RabbitMQ 发送消息
Sending messages from Java to RabbitMQ using com.rabbitmq.http.client.Client
我正在尝试从 Java 服务向 RabbitMQ 发送消息。
我正在使用一些 Java RabbitMQ 客户端库并尝试 运行 以下代码:
private static Client setAcceptAllSSL() throws Exception {
TrustStrategy acceptingTrustStrategy = (cert, authType) -> true;
SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build();
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
requestFactory = new HttpComponentsRestTemplateConfigurator(sslsf,sslContext);
return new Client(new ClientParameters().url(url).username(username).password(password).restTemplateConfigurator(requestFactory));
}
在最后一行(Client objectinitialization)中,抛出如下错误:
java.lang.NoClassDefFoundError:
org/springframework/http/converter/json/Jackson2ObjectMapperBuilder
我想我的 pom.xml 中可能遗漏了一些东西,或者 Spring 版本可能遗漏了一些东西。但是,我无法找到任何遗漏的 import/library/version 问题。
请帮忙:)
在pom.xml中添加这个jackson依赖:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.databind-version}</version>
</dependency>
我正在尝试从 Java 服务向 RabbitMQ 发送消息。
我正在使用一些 Java RabbitMQ 客户端库并尝试 运行 以下代码:
private static Client setAcceptAllSSL() throws Exception {
TrustStrategy acceptingTrustStrategy = (cert, authType) -> true;
SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build();
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
requestFactory = new HttpComponentsRestTemplateConfigurator(sslsf,sslContext);
return new Client(new ClientParameters().url(url).username(username).password(password).restTemplateConfigurator(requestFactory));
}
在最后一行(Client objectinitialization)中,抛出如下错误:
java.lang.NoClassDefFoundError: org/springframework/http/converter/json/Jackson2ObjectMapperBuilder
我想我的 pom.xml 中可能遗漏了一些东西,或者 Spring 版本可能遗漏了一些东西。但是,我无法找到任何遗漏的 import/library/version 问题。
请帮忙:)
在pom.xml中添加这个jackson依赖:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.databind-version}</version>
</dependency>