How to use the Spring WebClient with Jetty, instead of Netty?

Add dependency:

org.eclipse.jetty:jetty-reactive-httpclient:1.0.3

And then:

HttpClient httpClient = new HttpClient();
ClientHttpConnector connector = new JettyClientHttpConnector(httpClient);

WebClient webClient = WebClient.builder().clientConnector(connector).build();

Source: https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html#webflux-client-builder-jetty


Right now, in Spring Framework, WebClient has only one available ClientHttpConnector implementation, which is powered by Reactor Netty. This explains the current situation - using WebClient means you need Reactor Netty as a dependency.

Note that there's an existing issue about supporting Jetty Client as an alternative, see SPR-15092.