java - 无法在 flatMap 中构建 ResponseEntity
问题描述
我试图在 flatMap 方法中将 ClientResponse 转换为 ResponseEntity 但它返回一个错误。
代码:
Mono<ResponseEntity> response =
webClient.post()
.uri(requestURI)
.exchange()
.flatMap(clientResponse -> {
ResModel rm = new ResModel();
// call setter methods on rm
return ResponseEntity.ok(rm);
});
这会引发错误:
不存在类型变量 T 的实例,因此 org.springframework.http.ResponseEntity 符合 reactor.core.publisher.Mono)
我不明白为什么会发生此错误。我也尝试ClientResponse
在构建后返回修改但收到类似的错误。
我对 Spring 很陌生,并且已经在这个错误上花了将近 2 天的时间。我也尝试使用flatMapMany
这里提到的:https ://stackoverflow.com/a/52332137但得到同样的错误。
谁能告诉我如何解决这个问题以及为什么会发生这种情况
解决方案
推荐阅读
- flutter - 如何获取 Flutter 应用的构建和版本号
- dataframe - Pyspark -- java.lang.NullPointerException(使用 jdbc 从 Teradata 读取数据帧时)
- c# - Windows UWP BLE DeviceInformation.CreateWatcher 抛出属性键语法错误
- mysql - MySQL 8.0.13 组复制恢复错误 MY-002061
- java - 无法从方法返回相同的值,从它的子方法
- python - 多维索引切片后数组的维度
- python-3.x - RASA:尝试与机器人通信时出现连接中止错误
- android - 删除文本不会保存到 SQLite 数据库
- linux - 在 bash 脚本中用下划线替换连字符
- c++ - 如何删除约束集的子集并使用 c++/cplex 向该集添加新约束?