Unable to connect to Command Metric Stream

原因分析,我在网上找一些SpringCloud教程,其中遇到Hystrix 仪表板使用问题。

我使用的是SpringBoot2.0以上的版本。我参考的文章是用的SpringBoot2.0以下的老版本。

废话不多少,直接上解决方案:

在你的hystrix项目模块中写一个配置类就好了。

package site.clzblog.springcloud.servicehystrix.configuration;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class HystrixServletDefinitions {
    @Bean
    public ServletRegistrationBean servletRegistrationBean() {
        ServletRegistrationBean registration = new ServletRegistrationBean<>(
                new HystrixMetricsStreamServlet(), "/hystrix.stream");
        registration.setName("hystrixServlet");
        registration.setLoadOnStartup(1);
        return registration;
    }
}

你可能感兴趣的:(java,SpringCloud,proxy)