Feign说明
feign内部也是用Ribbon做负载均衡
声明式REST客户端(伪RPC),类是Android 的Retrofit调用方式
采用了基于接口的注解
描述现有wechatTask-guns中已经有helloWorld服务getToken服务
helloWorld访问无需带参数
http://127.0.0.1:8089//wechatTask//study/helloWorld
返回数据格式
image.png
在SpringCloud调用方msnSns模块的pom.xml中添加依赖
org.springframework.cloud
spring-cloud-starter-openfeign
在调用方的启动类添加注解
@EnableFeignClients
image.png
定义一个Feign接口(访问其他服务的接口,有点类似RetrofitClient)
/**
* 升级Spring Boot 2.1.0 Spring Cloud Greenwich.M1 版本后,在2个Feign接口类内定义相同的名字, @FeignClient(name = 相同的名字 就会出现报错
* https://blog.csdn.net/ankeway/article/details/83892752
*/
@FeignClient(name = "wechat-task") //name的值是Eureka注册的服务接口
public