hystrix.stream 访问一直ping并且Hystrix Dashboard 一直loading的问题

核能气质少年 提交于 2019-12-10 18:40:22

现象描述在访问hystrix.stream一直ping
在这里插入图片描述
Hystrix Dashboard一直loading 如图:
在这里插入图片描述

依赖加了

       <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

注解加了:

@SpringBootApplication
@EnableEurekaClient
@EnableCircuitBreaker
@EnableFeignClients//PROVIDER
public class ClientApplication {
    public static void main(String[] args) {
        SpringApplication.run(ClientApplication.class, args);
    }
}

配置文件也加了:

management:
  endpoints:
    web:
      exposure:
        include: env,health,metrics,info,hystrix.stream

调用方法也写了:

@RestController
public class ClientController {
    @Autowired
    private DemoClient demoClient;

    @RequestMapping("query")
    public String query() {
        return demoClient.query();
    }
}

还是不好使,为啥呢?
因为方法上面没有加注解 @HystrixCommand

@RestController
public class ClientController {
    @Autowired
    private DemoClient demoClient;

    @HystrixCommand(fallbackMethod = "fail2")
    @RequestMapping("query")
    public String query() {
        return demoClient.query();
    }

    private String fail2() {
        System.out.println("fail2");
        throw new RuntimeException();
    }
}

加上注解重启启动 在调用就好使了,原理还不太懂。继续研究中。。。
在这里插入图片描述
在这里插入图片描述

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!