SpringBoot2.x 整合SpringBoot-Admin監控 — QS11

SpringBoot2.x 整合 SpringBoot-Admin 監控

author: [email protected]

內容:

  1. SpringBoot2.x 整合 SpringBoot-Admin 監控
  2. 包含client及Server

更新日誌:

  1. 當前節點: 單體實例監控
  2. Demo download : https://github.com/wangyushuai/springboot-admin

效果預覽:
Server

Server

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)

  1. 新建SpringBoot子項目
  2. 並將子項目的porm文件中的父級配置爲 1步驟建好的父級項目(這樣就實現了由負極項目控制個版本號)
<parent>
    <groupId>com.example</groupId>
    <artifactId>springboot-admin</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</parent>

1.3 配置Server端

  1. 引入依賴

	<dependency>
		<groupId>de.codecentric</groupId>
		<artifactId>spring-boot-admin-starter-server</artifactId>
		 <version>2.1.1</version>
	</dependency>

  1. 設置端口號
server.port = 8090
  1. 添加啓動類註解
@Configuration
@EnableAutoConfiguration
@EnableAdminServer

1.4 配置Client端

  1. 添加依賴
  <dependency>
       <groupId>de.codecentric</groupId>
       <artifactId>spring-boot-admin-starter-client</artifactId>
       <version>2.1.1</version>
   </dependency>
  1. 配置文件
# 服務端監控地址
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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章