本模块简单演示了Spring Boot Admin。
本模块已将admin server注册为eureka客户端,所以不需要再增加admin client。
Spinrg Boot Admin可用于管理和监控基于Spring Boot的应用。
url | desc |
---|---|
http://localhost:8090 | spring boot admin ui |
- 引入Maven依赖
<properties>
<spring.boot.admin.server>1.5.0</spring.boot.admin.server>
...
</properties>
<!-- spring-boot-admin -->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server</artifactId>
<version>${spring.boot.admin.server}</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
<version>${spring.boot.admin.server}</version>
</dependency>
<!-- eureka 客户端 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
- 配置应用\端口等
以下是bootstrap.yml中相关配置
spring:
application:
name: admin
server:
port: 8090
eureka:
instance:
leaseRenewalIntervalInSeconds: 10
leaseExpirationDurationInSeconds: 30
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
- 启用AdminServer
增加@EnableAdminServer,启用Spring Boot Admin
增加@EnableDiscoveryClient,启用服务注册与发现
@EnableDiscoveryClient
@EnableAdminServer
@SpringBootApplication
public class SpringBootAdminServerApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootAdminServerApplication.class, args);
}
}
- Applications
- Journal