前言
Spring Boot Admin可以用來對Spring Boot應(yīng)用的運(yùn)行情況進(jìn)行監(jiān)控,分為服務(wù)端和客戶端,并提供了一個UI界面,2.0.1版本的界面采用Vue編寫,服務(wù)端采用Spring WebFlux + Netty的方式。
開始行動
pom.xml
這里我把服務(wù)端和客戶端的內(nèi)容放在一起,也就是自己監(jiān)控自己
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.asiainfo.aigov</groupId>
<artifactId>admin-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>admin-server</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!-- 服務(wù)端 begin -->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
<version>2.0.1</version>
</dependency>
<!-- 服務(wù)端 end -->
<!-- 客戶端 -->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>2.0.1</version>
</dependency>
</dependencies>
</project>
application.properties
#客戶端 begin
spring.boot.admin.client.url=http://localhost:8080
# 開啟所有端點(diǎn)
management.endpoint.health.show-details=ALWAYS
management.endpoints.web.exposure.include=*
#客戶端 end
這里用的是properties格式,如果使用yml格式,則
management:
endpoints:
web:
exposure:
include: "*"
*要用引號括起來,否則在解析的時候會報錯,*無法識別。
AdminServerApplication
package com.asiainfo.aigov.admin_server;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import de.codecentric.boot.admin.server.config.EnableAdminServer;
@EnableAdminServer //服務(wù)端
@SpringBootApplication
public class AdminServerApplication {
public static void main(String[] args) {
SpringApplication.run(AdminServerApplication.class, args);
}
}
啟動后訪問如下:

UI界面
結(jié)后語
在公司的家庭醫(yī)生項(xiàng)目中加了客戶端的配置后,出現(xiàn)solr和activemq自動開啟的情況,后來把a(bǔ)igov下的pom.xml里的solr和activemq相關(guān)的內(nèi)容注釋掉就正常了。