Spring boot actuator与Spring boot admin对接,2.0版本

本文介绍了如何使用Gradle构建工程,将Spring Boot Actuator与Spring Boot Admin 2.0版本进行对接。通过配置`spring-boot-admin-server`和`spring-boot-admin-client`的相关build.gradle及application.yml文件,可以实现系统的健康检查和信息展示。在对接过程中需要注意,要确保health检查为'up'状态,并且能够访问到info接口。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

gradle构建工程

spring-boot-admin-server

build.gradle

    compile group: 'de.codecentric', name: 'spring-boot-admin-starter-server', version: '2.0.0'
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: '2.0.2.RELEASE'
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-webflux', version: '2.0.2.RELEASE'
    compile group: 'org.jolokia', name: 'jolokia-core', version: '1.5.0'
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: '2.0.2.RELEASE'

application.yml

eureka:
    instance:
        preferIpAddress: true
        leaseRenewalIntervalInSeconds: 10
    client:
        registryFetchIntervalSeconds: 5
        service-url:
            defaultZone: ${EUREKA_SERVICE_URL:http://127.0.0.1:8080}/eureka/

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



#开启shutdown的安全验证
endpoint:
  health:
    sensitive: true
  cors:
    allowed-methods: HEAD,GET,POST
  shutdown:
  #启用shutdown
    enabled: true
    #禁用密码验证
    sensitive: false

spring-boot-admin-client

build.gradle

    // springboot client
    compile group: 'de.codecentric', name: 'spring-boot-admin-starter-client', version: '2.0.0'
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: '2.0.2.RELEASE'
//    compile group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: '2.0.2.RELEASE'
    compile group: 'org.jolokia', name: 'jolokia-core', version: '1.5.0'

application.yml

info:
  app:
    name: "server容器"
    description : "业务系统"
    version: "1.0"
    spring-boot-version : "2.0.2.RELEASE"
  version: "1.0"

#spring admin boot client config
management:
  server:
    port: 11002
    servlet:
      context-path: /
    ssl:
      enabled: false
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: always
spring:
    boot:
      admin:
        client:
          url: http://127.0.0.1:8080/administrator

启动即可完成

注意几点:

1、health为down增加

management:
  endpoint:
    health:
      show-details: always

2、只能访问info,添加

management:
  endpoints:
    web:
      exposure:
        include: "*"
其他问题应该不大,版本2.0版

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值