SpringBoot2.x 整合 SpringBoot-Admin 監控
author: [email protected]
內容:
- SpringBoot2.x 整合 SpringBoot-Admin 監控
- 包含client及Server
更新日誌:
- 當前節點: 單體實例監控
- Demo download :
https://github.com/wangyushuai/springboot-admin
效果預覽:
1.1 新建Mavne聚合工程
1.1.1 新建一個SpringBoot 父級項目
注意事項:
- 刪除porm.xml 文件中的
<relativePath/>
- 將父級項目打包成pom
<groupId>com.example</groupId>
<artifactId>springboot-admin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
1.2 新建子模塊(new Module)
- 新建SpringBoot子項目
- 並將子項目的porm文件中的父級配置爲 1步驟建好的父級項目(這樣就實現了由負極項目控制個版本號)
<parent>
<groupId>com.example</groupId>
<artifactId>springboot-admin</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
1.3 配置Server端
- 引入依賴
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
<version>2.1.1</version>
</dependency>
- 設置端口號
server.port = 8090
- 添加啓動類註解
@Configuration
@EnableAutoConfiguration
@EnableAdminServer
1.4 配置Client端
- 添加依賴
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>2.1.1</version>
</dependency>
- 配置文件
# 服務端監控地址
spring.boot.admin.client.url=http://127.0.0.1:8090
# 本機IP
spring.boot.admin.client.instance.service-base-url=http://127.0.0.1:8080/
# 開放監控內容
management.endpoints.web.exposure.include=*
# health/detail 細節()
management.endpoint.health.show-details = always