如何转换单声道<响应态度< object>>单声道< vernestity< void>>
嗨,我有一个api返回mono< wentermentity< void>
,API将调用另一个返回mono< wentermentity< object> gt; gt; gt; 的API从其他API到
mono< vernesponentity< void> 的结果?例如
public Mono<ResponseEntity<Void>> api() {
return anotherApi()
.map(response -> ResponseEntity.ok().build())
.onErrorReturn(ResponseEntity.badRequest().build());
}
,如果我只有MAP
,则可以使用以上有效,但是当我添加onerrorreturn
时,它不投诉类型不匹配:无法从Mono&lt; wendersentity&lt; explionentity&lt; object; object&gt; &gt;对于单声道&lt; verneslentity&lt; void&gt;
,为什么它成为mono&lt; wentermentity&lt; object&gt;&gt;&gt;
?
Hi I have an API returning Mono<ResponseEntity<Void>>
, the API will call another API which returns Mono<ResponseEntity<Object>>
, how do I convert the result from this other API to Mono<ResponseEntity<Void>>
? e.g.
public Mono<ResponseEntity<Void>> api() {
return anotherApi()
.map(response -> ResponseEntity.ok().build())
.onErrorReturn(ResponseEntity.badRequest().build());
}
The above works if I only have the map
, but not when I add the onErrorReturn
, it complains Type mismatch: cannot convert from Mono<ResponseEntity<Object>> to Mono<ResponseEntity<Void>>
, why has it become Mono<ResponseEntity<Object>>
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
代码是正确的,这只是无法正确推断键入的Java通用物。
您可以明确提供类型
,也可以移动
onerrorreturn
一个级别The code is correct and this is just Java generics that couldn't infer type correctly.
You could provide type explicitly
or move
onErrorReturn
one level up