java - Spring Boot:如何检索通过 Exchange Http Get 方法发送的请求对象?
问题描述
我是 SpringBoot 的新手,并试图弄清楚一切是如何工作的。我有一个关于如何从 MicroService2 检索请求对象的值的问题,它作为 HttpEntity 的一部分从 MicroService1 传递。我在 MicroService2 中尝试了@RequestBody ,但是“缺少所需的请求正文,出现错误”。
微服务1
{
HttpEntity<Object> entity=new HttpEntity<>(requestObject);
restTemplate.exchange(url,HttpMethod.GET,entity,Object.class);
}
微服务2
@GetMapping("/get-data")
public ResponseObject getResponse( ...... )
{
// How to Retrieve the requestObject values send from MicroService1
}
解决方案
推荐阅读
- c# - RabbitMQ 验证消息已发送
- javascript - ForgeViewer v7 - 损坏的 API。如何获取可视化列表
- c++ - 从由函数填充的字符串的推导向量到 int 的字符串
- javascript - Pg-promise - 可能参与事务/任务的可重用查询
- c# - 聊天机器人在本地机器人框架模拟器中正常工作,但在 azure 聊天机器人中不起作用
- swiftui - 如何让按钮转到右下角?
- java - 使用 Kotlin 或 Java 在我的 Activity 中访问 InCallService 或其他 Android 系统服务
- java - 编译失败:原因:com.android.tools.r8.CompilationFailedException:编译失败
- karate - 重用功能/场景响应
- mysql - 如果我在查询中添加 LIKE,如何获得相同的输出