springboot2.xxx使用hystrixDashboard遇到的坑

由于springcould版本问题使用hystrix遇到了神坑

首先 按照一篇博客所言配置好后访问监控页面出现了第一个问题:

在这里插入图片描述

一直在loading。。,请求调用后,没有数据输出。

按F12进入控制台调试发现报错信息:  Uncaught: TypeError: e.indexOf is not a function.

通过定位分析发现:

Hoxton依赖的jquery版本为3.4.1,定位到monitor.ftlh文件中,js的写法如下:

$(window).load(function()

修改方案:
修改monitor.ftlh为如下调用方式:
$(window).on("load",function()


编译jar源文件,重新打包引入后错误消失。

然而。。。。。。。。。。。。。。。。。。。。

又出现了如下错误:

springboot2.xxx使用hystrixDashboard遇到的坑_第1张图片

首先查看依赖是否添加全面

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

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

        
            org.springframework.boot
            spring-boot-starter-actuator
        

其次启动程序注解是否添加

@EnableCircuitBreaker
@EnableHystrixDashboard

如果都没问题那么检查下springboot 版本如果是2.0则需要添加 ServletRegistrationBean 因为springboot的默认路径不是 "/hystrix.stream",只要在自己的项目里配置上下面的servlet就可以了

@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;
    }

 

 

你可能感兴趣的:(springcloud)