【发布时间】:2020-03-30 07:39:57
【问题描述】:
我是 Spring WebFlux 的新手,但遇到了问题。我想返回类似Mono<String> 的内容,如下所示:
@PostMapping("/test")
public Mono<String> test(){
return Mono.just("Test String")
.thenEmpty(it -> {
// Do something I need
System.out.println("Print somethings");
})
.thenReturn("Return String");
}
我希望该方法返回Return String,但它什么也没返回。有什么问题?
【问题讨论】:
-
好像是java但是现在不能编译
-
@firegloves 对不起,我使用
kotlin并试图转换为java,但它可能有错误 -
如果您在 kotlin 中需要帮助,为什么不在 kotlin 中发帖?
-
@firegloves 因为知道 kotlin 的人很少。我修复了这个错误。
-
为什么要清空单声道?有什么原因吗?你读过 thenEmpty 的行为吗?你到底需要什么?
标签: spring-boot reactive-programming spring-webflux