java - 使用 com.rabbitmq.http.client.Client 从 Java 向 RabbitMQ 发送消息
问题描述
我正在尝试将消息从 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));
}
在最后一行(客户端对象初始化)中,抛出以下错误:
java.lang.NoClassDefFoundError: org/springframework/http/converter/json/Jackson2ObjectMapperBuilder
我想我的 pom.xml 中可能缺少某些内容,或者可能是 Spring 版本中的某些内容。但是,我找不到任何缺少的导入/库/版本问题。
请帮忙 :)
解决方案
在 pom.xml 中添加此 jackson 依赖项:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.databind-version}</version>
</dependency>
推荐阅读
- c# - .Net MVC 中使用 HttpClient 的 Json 对象序列化
- python - 使用opencv进行YUV帧平均
- apache-kafka - 我可以清空当地的卡夫卡国营商店吗
- python - 记录和 paramiko 奇怪的行为
- powershell - 使用 import-pssession 但使用 enter-pssession 时缺少对象方法
- python - 在我的不和谐机器人 python 中从维基百科获取解析器错误
- php - 创建表单时,我收到通知:未定义索引:
- sql - 未嵌套的 json 字符串数组
- android - 在 Fragment 中实现 onBackPressed()
- javascript - TypeScript 泛型创建实例