Two key points here WebClient:
- Its HTTP resources (connections, caches, etc.) are managed by the underlying referenced library
ClientHttpConnector, which you can configure toWebClient WebClientand WebClient.Builderare immutable
ClientHttpConnector , - , , . , WebClient WebClient.create(). Spring Boot , WebClient.Builder bean, .
WebClient WebClient.Builder , , . WebClient , ( , Servlet).
, :
WebClient baseClient = WebClient.create().baseUrl("https://example.org");
Mono<ClientResponse> response = baseClient.get().uri("/resource")
.header("token", "secret").exchange();
WebClient authClient = baseClient.mutate()
.defaultHeaders(headers -> {headers.add("token", "secret");})
.build();