Spring Boot 请求/actuator/beans 无法

作者: 虹猫日志 | 来源:发表于2019-11-14 09:56 被阅读0次

问题复现

在保证项目加入了spring-boot-starter-actuator依赖,并成功启动后。通过浏览器进行访问,返回如下图结果:

404

开始排查

1. 查看日志

日志记录
  • 通过日志可发现 /actuator 只给我们暴露了两个端点,我们不妨直接访问 /actuator 进行查看

2. 浏览器访问 /actuator

默认开放端点
  • 到此我们可以发现,Spring Boot 启动后默认只开放了infohealth两个端点,并没有开放beans端点,所以才会访问失败。

解决思路

beans端点进行开放
  • application.properties中加入如下配置:
# 开放所有端点,Spring-boot默认情况下Actuator只暴露了health和info端点
management.endpoints.web.exposure.include=*
  • 如果你的项目使用的application.yml,格式如下:
management:
  endpoints:
    web:
      exposure:
       include: "*"   # * 在yaml文件属于关键字,所以需要加引号

开放后效果如下图:

开放效果 beans 界面

以上IDEA翻译插件为 Translation ,浏览器 JSON 格式化插件为 JSON Viewer

相关文章

网友评论

    本文标题:Spring Boot 请求/actuator/beans 无法

    本文链接:https://www.haomeiwen.com/subject/ubplictx.html