0、在SpringBootTestConsumer项目
1、启动类添加@EnableCircuitBreaker
2、修改GreetingController类
@GetMapping("/get-greeting")
@HystrixCommand(fallbackMethod = "greetingFallBack")
public String greetingFallBack() {
return "fall back msg";
}
3、添加hystrix相关的依赖包
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-hystrix'
compile group: 'com.netflix.hystrix', name: 'hystrix-javanica'
4、只启动SpringBootTestConsumer
5、Feign已经集成了Ribbon,开启多个SpringBootTest的话,将会看到请求分散到多个实例上。