【发布时间】:2020-07-30 04:36:02
【问题描述】:
使用 WebClient 从多个非响应式的 REST API 获取响应是否存在任何问题。
【问题讨论】:
标签: spring-webflux spring-webclient
使用 WebClient 从多个非响应式的 REST API 获取响应是否存在任何问题。
【问题讨论】:
标签: spring-webflux spring-webclient
是的,你绝对可以,事实上,Spring 官方鼓励使用 WebClient。此外,通常作为基于 REST 的服务的首选通信方式的 RestTemplate 已被弃用。
此外,在非响应式上下文中使用 WebClient 也没有问题
https://docs.spring.io/spring/docs/5.2.8.RELEASE/spring-framework-reference/web.html#webmvc-client
但是,在非响应式上下文中使用 WebClient 时,您必须明确调用 subscribe 或 block。
【讨论】:
DO NOT post images of code, data, error messages, etc. - copy or type the text into the question. Please reserve the use of images for diagrams or demonstrating rendering bugs, things that are impossible to describe accurately via text.