(7)springcloud使用熔断器仪表盘监控

ribbon和feign用法一样

1.pom.xml中增加依赖


      org.springframework.cloud
      spring-cloud-starter-netflix-hystrix-dashboard

2.在Application上加注解@EnableHystrixDashboard

3.创建servlet

@Configuration
public class HystrixDashboardConfiguration {

    @Bean
    public ServletRegistrationBean getServlet() {
        HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
        ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
        registrationBean.setLoadOnStartup(1);
        registrationBean.addUrlMappings("/hystrix.stream");
        registrationBean.setName("HystrixMetricsStreamServlet");
        return registrationBean;
    }
}

4.浏览器

(7)springcloud使用熔断器仪表盘监控_第1张图片

 触发熔断器

(7)springcloud使用熔断器仪表盘监控_第2张图片

 再次点击

(7)springcloud使用熔断器仪表盘监控_第3张图片

你可能感兴趣的:(SpringCloud)