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
  • 相关阅读:
    arcEngine classic code(2)
    VisualGraph文档
    基于.net2 的CAD 绘图控件virtualGraph(2)
    沈阳三维GIS软件开发人员
    arcEngine + .net 2 AccessViolationException
    数据库事务并发带来的问题
    理解 WPF Dispatcher
    扇入与扇出
    IComparable 与 IComparer
    同步、异步、多线程
  • 原文地址:https://www.cnblogs.com/hoge66/p/11989912.html
Copyright © 2011-2022 走看看