(前提,你这个项目已经搭建好了可以在注册中心注册成功了)
1、添加引用
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
<version>2.2.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
<version>2.2.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-turbine</artifactId>
<version>2.2.8.RELEASE</version>
</dependency>
2、启动项就加上
@EnableTurbine
@EnableHystrixDashboard
3、application ,turbine.appConfig 跟上你服务提供者 的名称,还有监控对象白名单
turbine.appConfig=EUREKA-CLIENT,EUREKA-CLIENT2
turbine.clusterNameExpression=new String("default")
hystrix.dashboard.proxy-stream-allow-list=localhost
4、访问http://localhost:7031/hystrix,(7031就是你这个熔断集群 监控项目的端口)
在地址栏填上
http://localhost:7031/turbine.stream?cluster=default
最后点击按钮就行了
本文介绍如何通过添加依赖并配置应用属性,在Spring Cloud项目中启用Hystrix熔断机制及Turbine聚合监控,实现服务级别的故障隔离与监控。具体步骤包括:添加必要的Maven依赖;在启动类中开启@EnableTurbine和@EnableHystrixDashboard注解;设置application配置文件中turbine和hystrix的相关参数。
168万+

被折叠的 条评论
为什么被折叠?



