Feign结合Hystrix使用
1.先在父工程中添加依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</dependency>-->
<!--hystrix依赖,主要是用 @HystrixCommand -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
2.在调用端(消费端)配置文件开启熔断器
#开启熔断机制
feign.hystrix.enabled=true
#设置hystrix超时时间,默认是1000ms
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=6000
3.在创建interface·之后,还需要创建interface·对应的实现类,在实现类中实现接口中的方法,当出错了,输出方法中的内容
4.在接口中,定义@FeignClient的内容,fallback=实现类.class