HttpClient与SpringBoot结合使用
发布时间
阅读量:
阅读量
文章结构概述
SpringBoot官方并未为HttpClient提供专门的启动器。
尽管SpringBoot未内置相关启动器,但其仍提供了一个用于调用Restful服务的统一模板类——RestTemplate,该类在底层可借助HttpClient进行实现。借助这一功能,用户便无需自行定义APIService类。
- 1、引入maven坐标
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
- 2、在项目开发过程中,设计并实现一个名为HttpClientConfig的类,其功能与util类相似
#The config fo
全部评论 (0)
还没有任何评论哟~
