我可以使用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();
}
Run Code Online (Sandbox Code Playgroud)