SpringCloud 学习第二天 服务调用与负载均衡 openFeign

55 阅读1分钟

image.png

openFeign属于是全能王,既可以进行服务的调用还天生自带负载均衡

SpringCloud整合openFeign

1、在客户端模块添加openFeign坐标

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

2、在启动类上添加@EnableFeignClients注解

image.png

3、创建公共模块,注册服务模块的接口功能

image.png

4、创建controller调用公共模块的apis

image.png