继续上一篇,接下来Springcloud配置Turbine。
1、创建子模块Turbine
勾选Web、Actuator、Hystrix DashBoard、Turbine
子模块turbine的pom文件继承父工程,修改完如下:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.springcloud</groupId> <artifactId>daddy</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>turbine</artifactId> <version>0.0.1-SNAPSHOT</version> <name>turbine</name> <description>Demo project for Spring Boot</description> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-turbine</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
父工程daddy的pom文件添加对他的依赖
<module>turbine</module>
2、启动类
@EnableHystrixDashboard @EnableTurbine
3、配置文件
# turbine 项目端口号 server.port=8077 # turbine 项目实例名 spring.application.name=turbine # turbine 默认30秒主动向注册中心发送一次心态 eureka.instance.lease-renewal-interval-in-seconds=20 # turbine 需要去注册的地址,也就是eureka-server的地址+/eureka的后缀 eureka.client.serviceUrl.defaultZone=http://localhost:8070/eureka/ # actuator配置 management.endpoints.web.exposure.include=* management.endpoint.health.show-details=always # turbine配置 turbine.app-config=netflix-ribbon,open-feign turbine.aggregator.cluster-config=default turbine.cluster-name-expression="default"
4、启动测试
第一步运行:先分别把open-feign、netflix-ribbon监控画面运行起来
第二步访问路径:http://localhost:8077/hystrix
第三步填写路径:http://localhost:8077/turbine.stream
第四步Monitor Stream运行,页面如下:
最后配置成功!