zoukankan      html  css  js  c++  java
  • SpringCloud--Hystrix Dashboard界面一直loading的解决

    出现的问题

      在模拟Hystrix仪表盘时,仪表盘一直处于loading状态,没有监控数据

    探明原因及解决步骤

    我的SpringCloud版本是Hoxton.SR6

    1、确保hystrix.stream可以正常访问

      首先判断是否可以正常访问http://localhost:9000/actuator/hystrix.stream

      如果不能访问,需要做一下几点:

      (1)配置监控

      pom文件引入依赖

            <!--actuator 依赖-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-actuator</artifactId>
            </dependency>
            <!--eureka 客户端依赖-->
    
            <!-- hystrix-dashboard 依赖 -->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
                <version>2.2.7.RELEASE</version>
            </dependency>

      (2)启动类添加@EnableHystrixDashboard注解和@EnableHystrix注解,同时配置ServletRegistrationBean的访问路径

    @SpringCloudApplication
    @EnableHystrixDashboard
    @EnableHystrix
    public class ConsumerHystrixDashbord9000Application {
    
        public static void main(String[] args) {
            SpringApplication.run(ConsumerHystrixDashbord9000Application.class, args);
        }
    
        @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;
        }
    
    }

    2、确保hystrix.stream可以加载到数据

      如果上述内容配置完毕,访问http://localhost:9000/actuator/hystrix.stream一直提示ping,则说明还没有访问接口,服务还没有拿到负载均衡的数据,因此需要访问接口

        

     访问接口(如果项目不是热部署,则需要重启项目)

        

     此时再次访问http://localhost:9000/actuator/hystrix.stream,可以发现已经有数据

        

    3、其他情况(版本中JQuery报错)

      重新查看Hystrix仪表盘,发现仍然处于loading状态

      F12进入调试模式后,发现JQuery报错:Uncaught: TypeError: e.indexOf is not a function

        

      原因:Hoxton.SR6依赖的jquery版本为3.4.1。而在高版本jquery中$(window).load(function()写法已经被$(window).on("load",function()替代

      解决:修改jar包中jQuery中monitor.ftlh文件的load写法

      (1)maven仓库中找到Dashboard依赖的jar包

      注意:是spring-cloud-netflix-hystrix-dashboard目录下,不是spring-cloud-starter-netflix-hystrix-dashboard,虽然我们项目中引入的是spring-cloud-starter-netflix-hystrix-dashboard,但是可以看下依赖关系,最后还是使用的spring-cloud-netflix-hystrix-dashboard

      点击启动类上的@EnableHystrixDashboard注解,就可以看到具体引用的是哪个包了

        

       在本地maven仓库中找到该包,打开spring-cloud-netflix-hystrix-dashboard-2.2.3.RELEASE.jar emplateshystrix目录,修改monitor.ftlh

        

      修改内容就是将两处$(window).load(function()代码改为$(window).on("load",function()

        

       改好后,重新启动项目,重新访问负载均衡接口让其有数据,然后访问http://localhost:9000/actuator/hystrix.stream,即可正常访问

        

    ------------------------------------------------------------------
    -----------------------------------------------------------
    ---------------------------------------------
    朦胧的夜 留笔~~
  • 相关阅读:
    Realtime crowdsourcing
    maven 常用插件汇总
    fctix
    sencha extjs4 command tools sdk
    首次吃了一颗带奶糖味的消炎药,不知道管用不
    spring mvc3 example
    ubuntu ati driver DO NOT INSTALL recommand driver
    yet another js editor on windows support extjs
    how to use springsource tools suite maven3 on command
    ocr service
  • 原文地址:https://www.cnblogs.com/liconglong/p/14698763.html
Copyright © 2011-2022 走看看