1.添加pom文件
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
2.在启动类上,添加feign注解
@SpringBootApplication
@EnableFeignClients
public class EwbApplication {
public static void main(String[] args) {
SpringApplication.run(EwbApplication.class, args);
}
}
3.配置文件application.properties
# 启用熔断机制
feign.hystrix.enabled=true
4.定义接口
//新增fallback属性指定出现熔断由哪个类来处理
@Component
@FeignClient(value = "base", fallback = BaseHystrix.class)
public interface BaseService {
/**
* 获取员工的权限列表
*
* @param empId 员工id
*/
@GetMapping("/api/getEmpPermissions")
Result<List<String>> getEmpPermissions(@RequestParam(name = "em