1.建立可视化springboot服务端(建立springboot项目)
2.在服务端进行配置:
依赖:
<!-- 服务端springboot监控-->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
<version>2.3.1</version>
</dependency>
设置端口(避免冲突,在springboot配置文件中设置):
server.port=9999
3.需要监控的项目进行配置:
依赖:
<!-- springboot监控-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>2.3.1</version>
</dependency>
配置(yml,在springboot配置文件中设置):
# 执行admin.server地址
boot:
admin:
client:
url: http://localhost:9999 # 服务地址,端口与服务端一致。
instance:
prefer-ip: true # 显示IP
application:
name: springboot # 项目名称(该项目的项目名)
management:
endpoints:
enabled-by-default: true #暴露所有端点信息
web:
exposure:
include: '*' #以web方式暴露
endpoint:
health:
enabled: true # 开启健康检查详细信息
show-details: always