springboot 集成httpclient

来源:互联网 发布:淘宝闪电购 编辑:程序博客网 时间:2024/05/17 22:37

源码地址:https://github.com/li5454yong/springboot-httpclient.git
使用Spring集成httpclient时,需要复杂的配置文件spring管理httpclient。而使用SpringBoot来集成httpclient,我们只需要几个注解,一个java文件就能搞定。

pom文件

首先在与SpringBoot主配置同级的目录下建立一个class。

具体的http请求方法的封装这里就不在贴出来,大家可以通过上面的源码链接下载到完整的源码。

接下来写一个测试接口。

在浏览器中访问 http://localhost:8080/httpclient

可以看到后台打印的结果。