# httpClient-util **Repository Path**: wangshiminwork/httpClient-util ## Basic Information - **Project Name**: httpClient-util - **Description**: spring组件封装轻量级http接口调用工具 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 2 - **Created**: 2021-02-28 - **Last Updated**: 2022-06-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 执行打包到本地maven仓库命令 ``` mvn clean install ``` 导入依赖 ``` com.wsm.util httpClient-util 1.0.0-SNAPSHOT#注意版本号 ``` 开启httpClient工具组件 ``` //使用@EnableHttpClient注解开启httpClien组件 @EnableHttpClient @SpringBootApplication public class TestApplication { public static void main(String[] args) { SpringApplication.run(TestApplication.class, args); } } ``` 添加配置 ``` httpclient: #失败重试次数 retry-count: 3 #打印日志开关 log: response: true time: true url: true #http工具配置 util: max-time-out: 1000 max-total: 200 validate-after-inactivity: 1000 ``` 使用方法 ``` //可以使用${}表达式读取配置文件信息 也可直接输入地址 @Request("${baseUrl}") public interface HttpUtil { //@Post/@Get 注解发送post/get请求 value值接口地址 @Post("/test") //@Body注解是使用post的json形式 默认使用form表单提交 默认封装返回值类型 String saveUser(@Body User user); } //使用时直接使用@Autowired注解即可注入bean @Autowired(required = false) HttpUtil httpUtil; public String test(User user) { return httpUtil.saveUser(value); } ```