说明

  • Spring Boot Admin能够将 Actuator 中的信息进行界面化的展示,也可以监控所有 Spring Boot 应用的健康状况,提供实时警报功能。

  • Spring Boot Admin(简称SBA)由两部分组成:SBA ServerSBA Client

  • SBA Server: 提供Admin用户界面并独立运行,用于查看被监控的应用

    SBA Client: 被监控应用,注册到 SBA Server

SBA Server

  1. pom.xml 添加依赖

    版本要兼容 SpringBoot版本,

    1
    2
    3
    4
    5
    <dependency>
    <groupId>de.codecentric</groupId>
    <artifactId>spring-boot-admin-starter-server</artifactId>
    <version>2.2.3</version>
    </dependency>
  2. 启动类添加注解

    1
    @EnableAdminServer
  3. application.yml 配置

    1
    2
    server:
    port: 9111
  4. 访问系统 http://localhost:9111

SBA Client

/actuator/** 加入免 token

  1. pom.xml 添加依赖

    与 SBA Server 版本一致

    1
    2
    3
    4
    5
    <dependency>
    <groupId>de.codecentric</groupId>
    <artifactId>spring-boot-admin-starter-client</artifactId>
    <version>2.2.3</version>
    </dependency>
  2. application.yml 添加配置

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    spring:
    application:
    name: gateway
    boot:
    admin:
    client:
    url: "http://localhost:9111" # 指定 SBA Server 地址

    management:
    endpoints:
    web:
    exposure:
    include: "*"