spring-boot-admin 2.0小試牛刀

本文主要展現下spring-boot-admin 2.0版本的新特性前端

server實例

maven

<dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-starter-server</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jolokia</groupId>
            <artifactId>jolokia-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

配置

spring:
  application:
    name: spring-boot-admin-server
eureka:
  instance:
    preferIpAddress: true
    leaseRenewalIntervalInSeconds: 10
  client:
    registryFetchIntervalSeconds: 5
    serviceUrl:
      defaultZone: ${EUREKA_SERVICE_URL:http://localhost:8761}/eureka/

management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: ALWAYS

config

@Configuration
@EnableAutoConfiguration
@EnableAdminServer
public class AdminServerApplication {

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

client實例

maven

<dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-starter-client</artifactId>
            <version>2.0.0</version>
        </dependency>
                <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jolokia</groupId>
            <artifactId>jolokia-core</artifactId>
        </dependency>

配置

spring:
  boot:
    admin:
      client:
        url: http://localhost:8080
這裏配置admin server的地址

運行實例

wallboard

圖片描述

wallboard 實例詳情

圖片描述

applications

圖片描述

journal

圖片描述

小結

新版前端改用vue.js進行了重構,後端的話,使用event sourcing的原則進行了重構,支持spring5,移除了spring-cloud-starter依賴,另外使用WebClient替代了zuul等等,具體詳見spring-boot-admin-changes-with-2-xvue

對於client端來講,目前還不能像1.x版本那樣依靠Spring Cloud Discovery進行自動註冊,目前須要使用spring-boot-admin-starter-client。

doc

相關文章
相關標籤/搜索