Hystrix Dashboard 出现 Failed opening connection to 404 解决

1、Pom 文件(actuator、dashboard、javanica)

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

2、Main启动类

@SpringBootApplication
@EnableHystrixDashboard
public class DashBoard {
    public static void main(String[] args) {
        SpringApplication.run(DashBoard.class,args);
    }
    // 此配置是为了服务监控而配置,与服务容错本身无关,
    // ServletRegistrationBean因为springboot的默认路径不是"/hystrix.stream",
    // 只要在自己的项目里配置上下面的servlet就可以了
    @Bean
    public ServletRegistrationBean getServlet() {
        HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
        ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
        registrationBean.setLoadOnStartup(1);
        registrationBean.addUrlMappings("/hystrix.stream");
        registrationBean.setName("HystrixMetricsStreamServlet");
        return registrationBean;
    }
}

3、启动服务,浏览器输入http://localhost:${port}/hystrix

在这里插入图片描述

地址栏填写:
http://localhost:${port}/actuatr/hystrix.stream,这里port为服务提供者端口。

在这里插入图片描述
此时出现404错误,检查服务提供者pom文件是否包含actuator依赖,并且application.yml文件是否打开端点
在这里插入图片描述
在这里插入图片描述

management:
  endpoints:
    web:
      exposure:
        include: "*"

重启启动,运行,再次进入dashboard页面,如果一直显示Loading,可以先进入服务提供者的url,然后再进入dashboard。
在这里插入图片描述

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值