1.添加hystrix相关依赖
2,SchedualServiceHi接口的注解中加上fallback的指定类:
3.实现熔断处理类,并注入到容器
4.设置Hystrix可用,并启动项目
5.打开界面,输入地址 http://localhost:8903/hystrix,在输入框入 http://localhost:8903/hystrix.stream,开始执行监控
6.出现 “Unable to connect to Command Metric Stream.” 错误,网上大部分资料对于这个错误定位为jar包缺失,后面发现是2.0不支持这种方式集成,需要将jar包中的HystrixMetricsStreamServlet注入到容器中
7.改进,注入HystrixMetricsStreamServlet
@Bean
public ServletRegistrationBean getServlet(){
HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
ServletRegistrationBean regBean = new ServletRegistrationBean(streamServlet);
regBean.setLoadOnStartup(1);
List mappingList = new ArrayList();
mappingList.add("/hystrix.stream");
regBean.setUrlMappings(mappingList);
regBean.setName("hystrixServlet");
return regBean;
}
8.表盘正常显示
9 官方Dashboard面板内容说明如下:
PS:同样问题可参照博客 https://blog.csdn.net/ddxd0406/article/details/79643059