一、创建Spring Boot (版本2.0.3)admin监控服务端项目:demoServer;
1、引入依赖:
<!--Spring Boot Admin Server 服务端-->
<dependency> <groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
<version>2.0.1</version>
</dependency>
2、在启动类上添加@EnableAdminServer注解
二、创建Spring Boot (版本2.0.3)admin监控客户端项目:demoClient;
1、引入依赖:
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>2.0.1</version>
</dependency>
2、配置文件:
#定义客户端端口
server.port=8081
#配置服务端的路径+端口
spring.boot.admin.client.url=http://localhost:8080
#配置监控显示详细信息
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
三、启动服务端和客户端
访问服务端:http://localhost:8080/#/applications,出现以下界面,表示成功。