本 demo 主要演示了如何搭建一个 Spring Boot Admin 的服务端项目,可视化展示自己客户端项目的运行状态。
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
@EnableAdminServer
@SpringBootApplication
public class AdminServerApplication {
public static void main(String[] args) {
SpringApplication.run(AdminServerApplication.class, args);
}
}
server:
port: 8000
spring:
application:
name: spring-boot-demo-admin-server
boot:
admin:
instance-auth:
enabled: true
default-user-name: xkcoding
default-password: 123456
ui:
external-views:
- label: "xkcoding 🚀"
url: https://xkcoding.com
order: 2000
AdminServerApplication
,然后打开 http://localhost:8000
AdminClientApplication
,等待启动成功之后,观察是否成功注册上服务端