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源文件,重新打包引入后错误消失。

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

又出现了如下错误:

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

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

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

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

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值