栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

SpringCloud-Hystrix的DashBoard仪表盘功能笔记

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SpringCloud-Hystrix的DashBoard仪表盘功能笔记

1.父工程pom.xml中引入actuator依赖


            org.springframework.boot
            spring-boot-starter-actuator
        

2.服务调用方application.yml中添加相关配置

management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: always

3.服务调用方注册监控Servlet

@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;
 }

4.创建一个新的工程,仪表盘项目,发布到注册中心

server:
  port: 9000
eureka:
  instance:
    hostname: localhost
    prefer-ip-address: true
    instance-id: ${spring.cloud.client.ip-address}:${spring.application.name}:${server.port}:@project.version@
  client:
    service-url:
      defaultZone: http://localhost:8761/eureka/
    register-with-eureka: true
    fetch-registry: true
spring:
  application:
    name: dashboard
@SpringBootApplication
@EnableHystrixDashboard
public class DashBoardApplication {
    public static void main(String[] args) {
        SpringApplication.run(DashBoardApplication.class,args);
    }
}
        
            org.springframework.cloud
            spring-cloud-starter-netflix-hystrix
        
        
        
            org.springframework.cloud
            spring-cloud-starter-netflix-hystrix-dashboard
        
        
            org.springframework.cloud
            spring-cloud-starter-netflix-eureka-client
        

5.启动仪表盘项目,访问项目IP+端口/hystrix

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/356969.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号