秦皇岛做网站公司,企业网站建设的几种形式,网站外链建设可以提升网站权重对还是错,asp语言的网站建设在Spring Cloud中构建一个Hystrix Dashboard非常简单#xff0c;只需要下面四步#xff1a;愿意了解源码的朋友直接求求交流分享技术 一零三八七七四六二六 创建一个标准的Spring Boot工程#xff0c;命名为#xff1a;hystrix-dashboard。 编辑pom.xml#xff0c;具体依赖…在Spring Cloud中构建一个Hystrix Dashboard非常简单只需要下面四步愿意了解源码的朋友直接求求交流分享技术 一零三八七七四六二六 创建一个标准的Spring Boot工程命名为hystrix-dashboard。 编辑pom.xml具体依赖内容如下 parent
groupIdorg.springframework.cloud/groupId
artifactIdspring-cloud-starter-parent/artifactId
versionDalston.SR1/version
relativePath /
/parent
dependencies
dependency
groupIdorg.springframework.cloud/groupId
artifactIdspring-cloud-starter-hystrix/artifactId
/dependency
dependency
groupIdorg.springframework.cloud/groupId
artifactIdspring-cloud-starter-hystrix-dashboard/artifactId
/dependency
dependency
groupIdorg.springframework.boot/groupId
artifactIdspring-boot-starter-actuator/artifactId
/dependency
/dependencies
复制代码为应用主类加上EnableHystrixDashboard启用Hystrix Dashboard功能。
EnableHystrixDashboard
SpringCloudApplication
public class HystrixDashboardApplication {
public static void main(String[] args) {
SpringApplication.run(HystrixDashboardApplication.class, args);
}
}
复制代码根据实际情况修改application.properties配置文件比如选择一个未被占用的端口等此步非必须。 spring.application.namehystrix-dashboard
server.port1301
复制代码既然Hystrix Dashboard监控单实例节点需要通过访问实例的/hystrix.stream接口来实现自然我们需要为服务实例添加这个端点而添加该功能的步骤也同样简单只需要下面两步 在服务实例pom.xml中的dependencies节点中新增spring-boot-starter-actuator监控模块以开启监控相关的端点并确保已经引入断路器的依赖spring-cloud-starter-hystrix dependency
groupIdorg.springframework.cloud/groupId
artifactIdspring-cloud-starter-hystrix/artifactId
/dependency
dependency
groupIdorg.springframework.boot/groupId
artifactIdspring-boot-starter-actuator/artifactId
/dependency
复制代码确保在服务实例的主类中已经使用EnableCircuitBreaker或EnableHystrix注解开启了断路器功能。完整项目源码 转载于:https://juejin.im/post/5c67b30af265da2dbc597a5b