官网https://codecentric.github.io/spring-boot-admin/2.4.3/#getting-started
创建一个服务端配置
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
<version>2.4.3</version>
</dependency>
启动加上@EnableAdminServer
package com.tc.admin;
import de.codecentric.boot.admin.server.config.EnableAdminServer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Configuration;
@SpringBootApplication
//通过添加@EnableAdminServer到您的配置中来拉入 Spring Boot Admin Server配置
@EnableAdminServer
public class AdminApplication {
public static void main(String[] args) {
SpringApplication.run(AdminApplication.class, args);
}
}
配置客户端(可以多个)
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>2.4.3</version>
</dependency>
application.yaml
# 通过配置 Spring Boot 管理服务器的 URL 启用 SBA可视化客户端:
boot:
admin:
client:
url: http://127.0.0.1:8888 #配置服务端地址
instance:
prefer-ip: true #使用ip注册进来
#开启监控默认是开启
management:
endpoints:
enabled-by-default: true #暴露所有端点信息
# web方式暴露全部可访问
web:
exposure:
include: '*' #web方式暴露全部可访问
把两个服务模块都开启就可以了