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

后端 未结 2 753
既然无缘
既然无缘 2021-01-18 10:22

According to the documentation it is possible to use the Spring Reactive WebClient with a different server as Netty:

WebClient provides a higher level

相关标签:
2条回答
  • 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.

    0 讨论(0)
  • 2021-01-18 11:27

    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

    0 讨论(0)
提交回复
热议问题