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
  • 相关阅读:
    常用和实用的git命令,让你快速入门git
    如何获取电脑的IP和mac地址
    关于vue插件的使用和修改
    BullsEye游戏优化布局
    BullsEye游戏总结
    Android游戏小demo
    算法及相应算法应用之令牌桶算法
    php IDE之phpStorm使用小记
    php中openssl_encrypt方法
    mysql界面工具
  • 原文地址:https://www.cnblogs.com/hoge66/p/11989912.html
Copyright © 2011-2022 走看看