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

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容