spring cloud hystrix dashboard 没有/actuator/hystrix.stream路径解决

首先我用的是spring boot Greenwich.SR2

在测试hystrix-dashboard监控服务时,发现访问localhost:9001/actuator/hystrix.stream一直失败

去网上搜了一下,发现启动类要添加一个servlet

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

要引入的依赖有以下

        
            org.springframework.cloud
            spring-cloud-starter-netflix-eureka-server
            2.1.2.RELEASE
        
        
            org.springframework.cloud
            spring-cloud-starter-openfeign
            2.1.2.RELEASE
        
        
            org.springframework.cloud
            spring-cloud-starter-netflix-hystrix
        
        
            org.springframework.cloud
            spring-cloud-starter-netflix-archaius
        
        
            org.springframework.cloud
            spring-cloud-starter-netflix-hystrix-dashboard
        
        
            org.springframework.boot
            spring-boot-starter-actuator
        

 

转载于:https://www.cnblogs.com/xc-chejj/p/11316143.html

你可能感兴趣的:(spring cloud hystrix dashboard 没有/actuator/hystrix.stream路径解决)