1.新建模块,导入feign的依赖jar包
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-openfeign</artifactId> </dependency>
2.实体类
你需要调用的模块的实体
3.接口
@FeignClient("userServer") #调用模块的服务名称 接口上
@GetMapping("user/{id}") #以什么方式请求 方法上
4.配置类
public Logger.Level loglevel(){ return Logger.Level.BASIC; } #日志打印
5.使用
引入到需要使用feign的模块中 在其服务类中使用其接口调用