Hysrix 断路器
首先引入依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
修改application类并加入注解,当@EnableCircuitBreaker,@EnableEurekaClient,@SpringBootApplication三个注解同时存在时可以使用@SpringCloudApplication注解
加入注解,指定降级的方法 @HystrixCommand(fallbackMethod = "error")
Hysrix仪表盘
引入依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
修改application类加入@EnableHystrixDashboard注解
接下来输入地址 http://localhost:8081/hystrix,选择集群或则单体,设置时间和title,点击monitor stream 按钮就可以看到服务的断路详情了。
文章来源: https://blog.csdn.net/qq_36760953/article/details/91460450