SpringBoot Admin的搭建和使用

springboot admin 服务端

  • 依赖
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'de.codecentric:spring-boot-admin-starter-server'
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
  • 这里用的是gradle,主要是spring-boot-admin-starter-server依赖,在加上注解
@EnableAdminServer

服务端搭建完成


springboot admin 客户端

  • 依赖
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'de.codecentric:spring-boot-admin-starter-client'
    implementation 'org.springframework.boot:spring-boot-starter-actuator'

    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
  • 配置文件
spring:
  application:
    name: admin-client-sqr
  boot:
    admin:
      client:
        url: http://localhost:5006 #服务端的地址


#配置暴露端点才能在admin页面上显示所有信息
management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: always

#配置好log文件路径可在springbootadmin页面在线查看日志
logging:
  file: ./logs/adminclient.log

你可能感兴趣的:(SpringBoot Admin的搭建和使用)