Spring Boot Admin 2.0.1实践

前言

Spring Boot Admin可以用来对Spring Boot应用的运行情况进行监控,分为服务端和客户端,并提供了一个UI界面,2.0.1版本的界面采用Vue编写,服务端采用Spring WebFlux + Netty的方式。

开始行动

pom.xml

这里我把服务端和客户端的内容放在一起,也就是自己监控自己


    4.0.0
    
        org.springframework.boot
        spring-boot-starter-parent
        2.0.1.RELEASE
         
    
    com.asiainfo.aigov
    admin-server
    0.0.1-SNAPSHOT
    jar
    admin-server
    http://maven.apache.org

    
        UTF-8
        1.8
    

    
        
        
            de.codecentric
            spring-boot-admin-server
            2.0.1
        
        
            de.codecentric
            spring-boot-admin-server-ui
            2.0.1
        
        
        
        
            de.codecentric
            spring-boot-admin-starter-client
            2.0.1
        
    

application.properties

#客户端 begin
spring.boot.admin.client.url=http://localhost:8080
# 开启所有端点
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 //服务端
@SpringBootApplication
public class AdminServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(AdminServerApplication.class, args);
    }
}

启动后访问如下:


UI界面

结后语

在公司的家庭医生项目中加了客户端的配置后,出现solr和activemq自动开启的情况,后来把aigov下的pom.xml里的solr和activemq相关的内容注释掉就正常了。

你可能感兴趣的:(Spring Boot Admin 2.0.1实践)