声明式远程调用OpenFeign(微服务调用微服务)

通过注册中心nacos进行远程调用

如何远程调用别的服务

   1引入依赖

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>

2编写一个调用远程的接口,给springcloud,在接口中编写需要调用远程服务的某某请求

3开启feign远程调用功能@EnableFeignClients


报错,缺loadbalancer
Caused by: java.lang.IllegalStateException: No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalancer?
参考
https://blog.csdn.net/weixin_45729934/article/details/110310119

会员服务


Did you forget to include spring-cloud-starter-loadbalancer?
spring cloud版本过高之后,没有包含负载均衡的包


测试代码

最终会员微服务 调用   优惠券服务 远程调用成功

原文地址:https://www.cnblogs.com/daofree/p/14204858.html