在日常工作中,我们经常会遇到需要调用内部 API 或者第三方 API 的情况,主要有以下方式:
一、HttpURLConnection
占坑
二、HttpClient
<!--HttpClient-->
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<!--CloseableHttpClient-->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.12</version>
</dependency>
其中,官方的commons-httpclient已经整合到org.apache.httpcomponents
三、OKHttp
占个坑
四、RestTemplate
https://blog.csdn.net/u012843361/article/details/79893638
参考文档
https://www.cnblogs.com/swordfall/p/10757499.html
集成了
①通过JDK网络类Java.net.HttpURLConnection;
②通过common封装好的HttpClient;
③通过Apache封装好的CloseableHttpClient;
④通过SpringBoot-RestTemplate;