①依赖
②配置文件
③两种方式实现熔断
⑴restTemplate
⑵FeignClient
①依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
②配置文件
application.properties添加这一条:
feign.hystrix.enabled=true
③两种方式实现熔断
提供一个服务名称 让熔断器监控这个服务,一旦可用服务全部宕机,调用fallback 函数
⑴restTemplate
//添加注解
@RestController
@RefreshScope
public class xxx{
//调用restTemplate
@Resource
private RestTemplate restTemplate;
//编写java方法
public String xxxx(){
System.out.println("ConsumerController.testRest1");
HttpEntity<Object> requestData = new HttpEntity<>("