Java调用Http/Https接口(7)--WebClient调用Http/Https接口

WebClient是Spring提供的非阻塞、响应式的Http客户端,提供同步及异步的API,将会代替RestTemplate及AsyncRestTemplate;本文主要介绍WebClient的基本使用,文中所使用到的软件版本:Java 1.8.0_191、SpringBoot 2.2.1.RELEASE。

1、服务端

参见Java调用Http接口(1)--编写服务端 

2、调用

使用WebClient需要用到Reactor Netty,依赖如下:

<dependency> <groupId>org.springframework</groupId> <artifactId>spring-webflux</artifactId> </dependency> <dependency> <groupId>io.projectreactor.netty</groupId> <artifactId>reactor-netty</artifactId> </dependency>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zzygpf.html