详解SpringBoot中RestTemplate的几种实现
更新时间:2019年11月04日 10:29:36 作者:李海峰
这篇文章主要介绍了详解SpringBoot中RestTemplate的几种实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
RestTemplate的多种实现
使用JDK默认的http library
使用Apache提供的httpclient
使用Okhttp3
@Configuration public class RestConfig { @Bean public RestTemplate restTemplate(){ RestTemplate restTemplate = new RestTemplate(); return restTemplate; } @Bean("urlConnection") public RestTemplate urlConnectionRestTemplate(){ RestTemplate restTemplate = new RestTemplate(new SimpleClientHttpRequestFactory()); return restTemplate; } @Bean("httpClient") public RestTemplate httpClientRestTemplate(){ RestTemplate restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory()); return restTemplate; } @Bean("OKHttp3") public RestTemplate OKHttp3RestTemplate(){ RestTemplate restTemplate = new RestTemplate(new OkHttp3ClientHttpRequestFactory()); return restTemplate; } }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。
相关文章
Java利用Request请求如何获取IP地址对应的省份、城市详解
之前已经给大家介绍了关于Java用Request请求获取IP地址的相关内容,那么下面这篇文章将给大家进入深入的介绍,关于Java利用Request请求如何获取IP地址对应省份、城市的相关资料,需要的朋友可以参考借鉴,下面来一起看看吧。2017-10-10Hadoop 使用IntelliJ IDEA 进行远程调试代码的配置方法
这篇文章主要介绍了Hadoop 使用IntelliJ IDEA 进行远程调试代码的配置方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下2021-04-04spring如何集成cxf实现webservice接口功能详解
这篇文章主要给大家介绍了关于spring如何集成cxf实现webservice接口功能的相关资料,文中通过示例代码介绍的非常详细,对大家 的学习或者工作具有一定的参考学习价值,需要的朋友们下面来一起看看吧2018-07-07
最新评论