11.4.1 通过 GET 方式获取资源
Mono<Ingredient> ingredient = WebClient.create()
.get()
.uri("http://localhost:8080/ingredients/{id}", ingredientId)
.retrieve()
.bodyToMono(Ingredient.class);
ingredient.subscribe(i -> { ... })Flux<Ingredient> ingredients = WebClient.create()
.get()
.uri("http://localhost:8080/ingredients")
.retrieve()
.bodyToFlux(Ingredient.class);
ingredients.subscribe(i -> { ... })使用基础 URI 发送请求
@Bean
public WebClient webClient() {
return WebClient.create("http://localhost:8080");
}对长时间运行的请求进行超时处理
最后更新于