【发布时间】:2021-04-24 15:13:41
【问题描述】:
我在我的项目中使用Spring Boot Actuator 模块,它公开了 REST 端点 URL 来监控和管理生产环境中的应用程序使用情况,而无需对其中任何一个进行编码和配置。
默认情况下,仅公开 /health 和 /info 端点。
我正在根据我的用例通过application.properties 文件自定义端点。
application.properties.
#To expose all endpoints
management.endpoints.web.exposure.include=*
#To expose only selected endpoints
management.endpoints.jmx.exposure.include=health,info,env,beans
我想了解,Spring Boot 究竟在哪里为 /health 和 /info 创建实际端点,以及它如何通过 HTTP 公开它们?
【问题讨论】:
-
还可以查看 Endpoint 的 Javadoc 和相关/链接的类:docs.spring.io/spring-boot/docs/current/api/org/springframework/…
-
不清楚您要解决什么问题。想看spring-boot-actuator的源码吗?它在此处可用:github.com/spring-projects/spring-boot/tree/master/…,查看并查看使用
@Endpoint注释的 IDE。您会看到 EndpointRequestMatcher 依次由执行器引擎调用,但我怀疑这些信息是否足以解决您面临的问题(无论是什么 :)) -
感谢 Puce 和 Mark Bramnik 为我指明了正确的方向。感谢指导!我添加了一个答案作为我的问题的解决方案,以防人们将来需要类似的东西。
标签: java spring spring-boot spring-boot-actuator