# spring-boot-open-feign-starter **Repository Path**: ychuanl/spring-boot-open-feign-starter ## Basic Information - **Project Name**: spring-boot-open-feign-starter - **Description**: No description available - **Primary Language**: Java - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-12-31 - **Last Updated**: 2021-04-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # spring-boot-open-feign-starter #### 介绍 open-feign 一个优秀的http客户端框架,但是跟spring boot 集成没有相关的starter,所以自己实现一个方便与springboot集成 使用该项目 你应该对open-feign有一定的了解 #### 软件架构 软件架构说明 #### 安装教程 1. 引入maven依赖 ```xml top.magicpotato spring-boot-open-feign-starter 11.0.1 ``` #### 使用说明 1. 创建feign对应的接口,再接口上标注注解 ```java // 参数指定的是 网址前缀 如果${xxx}的形式会从 application.properties 配置文件中获取 @FeignClient("http://www.magicpotato.top/") public interface BaiDuClient { /** * 使用方式同feign (https://github.com/OpenFeign/feign) * @return */ @RequestLine("GET query-count") String index(); } ``` 2. 指定接口所在的包路径 ```java @SpringBootApplication // 会扫描这个包下所有标注@FeignClient注解的接口 @FeignScan("com.example.demo.feignClient") public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } } ``` 3. 注入接口类并使用 ```java @RequestMapping("/test") public class HelloController { // 注入接口类 @Autowired private BaiDuClient baiDuClient; @GetMapping("/hello") @ResponseBody public String hello() { // 直接使用 return baiDuClient.index(); } } ``` #### 自定义配置 目前支持,自定义http客户端、编码、解码器 只需创建对应的bean即可 ```java // 当前默认实现 // 客户端 this.client = new Client.Default(null, null); // 解码器:是默认解码器 通常返回字符串类型 this.decoder = new Decoder.Default(); // 编码器:使用jackson编码器 输入参数会序列化成json字符串 this.encoder = new JacksonEncoder(); ``` #### 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request