1、搭建springboot admin server
1.1、pom文件
<properties>
<!--和springboot-parent版本對應,否則啓動報錯-->
<spring-boot-admin.version>2.0.0</spring-boot-admin.version>
</properties>
<dependencies>
<!-- 該依賴依賴了admin-server和admin-server-ui -->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
</dependency>
<!--springboot admin-->
<!--<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
<version>2.0.0</version>
</dependency>-->
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-dependencies</artifactId>
<version>${spring-boot-admin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
1.2、啓動類打上@EnableAdminServer註解
2、搭建springboot admin client
2.1、pom文件
<!--引入springboot admin client,該依賴依賴了springboot性能監控 -->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<!--與springboot-parent版本對應,否則啓動報錯 -->
<version>2.0.0</version>
</dependency>
<!--springboot性能監控-->
<!--<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>-->
2.2、application.yml
server:
port: 8081
spring:
application:
name: springboot-swagger2-demo
boot:
admin:
client:
url: http://localhost:8080
#/health 展示了進程的健康狀態
#/beans 程序創建的Bean
#/configprops 配置信息,屬性值
#/env 環境屬性
#/info info開頭的程序屬性信息
#/metrics 度量指標,比如JVM和HTTP請求等
#/trace HTTP的詳細請求信息
#/mappings 所有的URL路徑映射關係
#/dump 線程快照信息
#/heapdump 內存快照信息
management:
endpoints:
web:
exposure:
include: '*'
endpoint:
health:
#enabled: false #關閉某個接口
show-details: always