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
  • 相关阅读:
    2018.12.29-dtoj-3626
    2018.12.28-bzoj-3784-树上的路径
    2018.12.28-bzoj-2006-[NOI2010]超级钢琴
    2018.12.28-dtoj-3648-寝室管理
    2018.12.27-dtoj-4089-line
    2018.12.27-dtoj-3151-相遇
    2018.12.25-dtoj-4086-针老师(truth) || dtoj-3657: 排列(permutation)
    不要62 hdu2089
    Kia's Calculation hdu4726
    The Moving Points hdu4717
  • 原文地址:https://www.cnblogs.com/hoge66/p/11989912.html
Copyright © 2011-2022 走看看