【SpringBoot】spring-boot-starter-actuator的使用

添加spring-boot-starter-actuator依赖,可以查看应用的监控状态、日志级别、请求mapping等配置,使用步骤如下

1、修改pom文件

在pom文件中添加下面依赖(注意:因为在父工程中管理了版本信息,所以moudle没有指定版本号)

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

2、application.yaml添加配置

这里只给出了部分测试配置,注意在生产环境中安全问题,不暴露敏感信息

management:
  endpoints:
    web:
      exposure:
        include: mappings,health,info

3、测试

浏览器访问:http://localhost/actuator
返回结果:

{
  "_links": {
    "self": {
      "href": "http://localhost/actuator",
      "templated": false
    },
    "health": {
      "href": "http://localhost/actuator/health",
      "templated": false
    },
    "health-path": {
      "href": "http://localhost/actuator/health/{*path}",
      "templated": true
    },
    "info": {
      "href": "http://localhost/actuator/info",
      "templated": false
    },
    "mappings": {
      "href": "http://localhost/actuator/mappings",
      "templated": false
    }
  }
}

测试访问mapping
在这里插入图片描述

  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值