- 建立项目monitor,加入maven依赖,一般情况会与注册中心配合使用。所以也加入了eureka客户端依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</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>
- 监控中心启动类
@SpringBootApplication
@EnableDiscoveryClient
@EnableHystrixDashboard
@EnableTurbine
public class MonitorApplication {
public static void main(String[] args) {
SpringApplication.run(MonitorApplication.class, args);
}
}
- 配置文件application.yml
server:
port: 8301
spring:
application:
name: monitor-center
profiles:
active: dev
turbine:
aggregator:
cluster-config: default
- 开发环境application-dev.yml
eureka:
client:
service-url:
defaultZone: http://root:zxy2019@192.168.2.90:8001/eureka/
instance:
hostname: ${spring.cloud.client.ip-address}
instance-id: ${eureka.instance.hostname}:${server.port}
prefer-ip-address: true