【发布时间】:2021-08-30 16:10:35
【问题描述】:
我可以使用现在已弃用的 exchange() 方法将 WebClient 响应转换为响应实体。
请提出其他实现相同结果的方法。下面是我的代码。
public ResponseEntity<TestClass> getTestDetails() {
ClientResponse clientResponse = webClientBuilder.build()
.get()
.uri("http://localhost:9090/test")
.headers(httpHeaders -> {
httpHeaders.add(Constants.ACCEPT, Constants.APPLICATION_JSON);
})
.exchange()
.block();
return clientResponse.toEntity(TestClass.class).block();
}
【问题讨论】:
标签: spring spring-boot reactive-programming spring-webflux