zoukankan      html  css  js  c++  java
  • springcloud hystrix-dashboard improve faliure.

    1、单单引入一个教程上的,不行;按照下面的pom进行修改

    <dependency>
    			<groupId>com.netflix.hystrix</groupId>
    			<artifactId>hystrix-javanica</artifactId>
    			<version>RELEASE</version>
    		</dependency>
    
    		<!--<dependency>
    			<groupId>org.springframework.cloud</groupId>
    			<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
    		</dependency>-->
    		<dependency>
    			<groupId>org.springframework.cloud</groupId>
    			<artifactId>spring-cloud-netflix-hystrix-dashboard</artifactId>
    		</dependency>
    

      

    success!

    2、run the application,but the view like this:

    What's the problem ?

    This is a single project,if the other projects could use hystrix,you need to add hystrix code into the other project.like this:

    package com.bcd.cloud.pf.ribbon;
    
    import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.boot.web.servlet.ServletRegistrationBean;
    import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
    import org.springframework.cloud.client.loadbalancer.LoadBalanced;
    import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
    import org.springframework.cloud.netflix.hystrix.EnableHystrix;
    import org.springframework.context.annotation.Bean;
    import org.springframework.web.client.RestTemplate;
    
    
    /**
     * RibbonApplication class
     *
     * @EnableEurekaClient was created by myself
     * @EnableHystrix was created by myself ,断路由
     *
     * @author myself
     * @date 2019/12/05
     */
    @SpringBootApplication
    //@EnableEurekaClient
    @EnableDiscoveryClient
    @EnableHystrix
    public class RibbonApplication {
    
    	public static void main(String[] args) {
    		SpringApplication.run(RibbonApplication.class, args);
    	}
    
    	/**
    	  *  加入restTemplate以消费相关的服务。
    	* */
    	@Bean
    	@LoadBalanced
    	RestTemplate restTemplate()
    	{
    		return new RestTemplate();
    	}
    
    	@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;
    	}
    }
    

      Reboot the 8764 project.and input the url like this:

    http://localhost:8764/actuator/hystrix.stream

    www.beicaiduo.com
  • 相关阅读:
    Q15格式表示负小数
    音频算法处理笔试面试题
    有符号和无符号之间的转化
    PE5 Smallest multiple
    PE3 Largest prime factor(最大素数因子)
    PE2 Even Fibonacci numbers(最大菲波那列偶数)
    PE 4 Largest palindrome product(最大回文)
    PE1 Multiples of 3 and 5
    Codevs高精度入门(减法、加法和乘法)解题报告
    计算机网络学习笔记(二) 计算机网络结构
  • 原文地址:https://www.cnblogs.com/hoge66/p/11989912.html
Copyright © 2011-2022 走看看