新建模块加入依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
无需添加其他任何依赖, 该依赖已经包括spring-boot-start-web
修改yml
server:
port: 9001
添加主启动类
//开启hystrix dashboard
@EnableHystrixDashboard
@SpringBootApplication
public class MicrosoftHystrixDashboard9001Application {
public static void main(String[] args) {
SpringApplication.run(MicrosoftHystrixDashboard9001Application.class, args);
}
}
服务提供者yml
management:
endpoints: #通过http://localhost:8081/actuator/${endpoints}来访问
web:
exposure: #暴露endpoints,默认对web暴露health和info
include: "*"
这里需要额外对web开启hystrix.stream
endpoint
或是指定include: "info,health,hystrix.stream"
访问localhost:9001/hystrix
? 出现页面表示成功
Delay表示多少时间检查一次
Title表示监视的服务提供者的名字, 可以自定义, 对应Hystrix Stream
访问localhost:8081/actuator/hystrix.stream
, hystrix-app是服务提供者的ip
消费者发送一次请求
出现如下页面表示成功
只会对有@EnableHystrix和@HystrixCommand注解的服务模块生效, 不会对api模块中配置的FabllbackFactory生效
原文:https://www.cnblogs.com/kikochz/p/12877547.html