1.pom配置
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
2.开启远程调用
假设是 A 服务调用 B 服务
在 A 服务开启@EnableFeignClients(basePackages = “com.xxx.xxxt”)
3.声明远程接口
在 A 服务中使用@FeignClient(“B 服务”)声明需要进行远程调用的服务
注意 @RequestMapping 的路径是类路径 + 方法上的路径
4.测试
所以访问 A 服务 :http://localhost:8000/member/member/coupons 时,会转发到 B 服务:http://localhost:7000/coupon/coupon/member/list