Spring Boot - 将 /health 端点的位置更改为 /ping/me

2024-01-05

我设置了endpoints.health.path财产给/ping/me。但我无法使用访问端点http://localhost:9000/ping/me http://localhost:9000/ping/me它仅适用于http://localhost:9000/health http://localhost:9000/health。我缺少什么? 这是应用程序属性文件中的代码。

#Configuration for Health endpoint
endpoints.health.id=health
endpoints.health.path=/ping/me
endpoints.health.enabled=true
endpoints.health.sensitive=false

#Manage endpoints
management.port=9000
management.health.diskspace.enabled=false

我得到的回应是:

{
"timestamp" : 1455736069839,
"status" : 404,
"error" : "Not Found",
"message" : "Not Found",
"path" : "/ping/me"
}

在 Spring Boot 2.0.0 中,Actuator 变得与技术无关,因此它现在与 MVC 无关。因此,如果您使用 Spring Boot 2.0.x,则只需添加以下配置属性:

# custom actuator base path: use root mapping `/` instead of default `/actuator/`
management.endpoints.web.base-path=

# override endpoint name for health check: `/health` => `/ping/me`
management.endpoints.web.path-mapping.health=/ping/me

如果你不覆盖management.endpoints.web.base-path,您的健康检查将在/actuator/ping/me.

属性如endpoints.*在 Spring Boot 2.0.0 中已弃用。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Spring Boot - 将 /health 端点的位置更改为 /ping/me 的相关文章

随机推荐