zoukankan      html  css  js  c++  java
  • SpringBoot集成actuator模块的基本使用

    © 版权声明:本文为博主原创文章,转载请注明出处

    1. 版本
      
    SpringBoot:2.0.0.RELEASE

    2. 集成

      SpringBoot集成actuator模块非常简单,只需要引入actuator模块的依赖即可。

    <dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>

    3. 访问

      书上写的访问方式为:http://ip:port/health;但是我访问一直报错400,百度的结果跟书上一致。

      最后查询官方文档,发现2.0.0.RELEASE的访问方式已经变了,最新访问方式为:http://ip:port/actuator/health

    4. 配置

      > actuator默认的访问端口跟项目端口一致,但也可自己指定

    management:
      server:
        port: 8100

      > actuator访问必须通过JMX和HTTP,但是使用HTTP默认只暴露health和info,因此想访问其他端点需自己配置

    management:
      endpoints:
        web:
          exposure:
            exclude: shutdown,info  # 排除端点,不可访问;多端点之间用逗号分隔
            include: httptrace,env  # 包含端点,可以访问;多端点之间用逗号分隔

       > 在Spring Boot 2.0.0.RELEAS版本中,访问health端口,只能查询系统的状态,不能查看详细的信息。若想查看所需信息,需进行如下配置

    management:
      endpoint:
        health:
          show-details: always

      其中show-details的值有三个:never,when-authorized,always。具体含义如下:

        never:从不展示详情(默认)

        when-authorized:详情只展示给授权用户,授权角色可使用 management.endpoint.health.roles 进行配置

        always:展示详情给所有用户

    参考:

    https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-endpoints

  • 相关阅读:
    JavaSE Day11
    JavaSE Day10
    JavaSE Day9
    JavaSE Day8
    JavaSE Day7
    a
    js 操作 字符串
    委托的生明与使用
    T-SQL 的简单查询语句
    asp.net服务控件的生命周期
  • 原文地址:https://www.cnblogs.com/jinjiyese153/p/8607895.html
Copyright © 2011-2022 走看看