[英]How to point a single spring actuator endpoint to the root ("/")
I have a requirement to expose a health endpoint on the root path on the specific port.我需要在特定端口的根路径上公开一个健康端点。
However, root path is reserved for the actuator endpoints overview and I could not find a way to overwrite that overview functionality with the specific endpoint functionality.但是,根路径是为执行器端点概览保留的,我找不到用特定端点功能覆盖该概览功能的方法。
This DOES NOT work:这不起作用:
management.endpoints.web.base-path=/
management.endpoints.web.path-mapping.health=""
As a workaround, I created a rest controller which redirects "/" to "/actuator/health".作为解决方法,我创建了一个 rest controller 将“/”重定向到“/actuator/health”。 But it looks ugly.
但它看起来很难看。 Does anybody know a better solution?
有人知道更好的解决方案吗?
在与多名工程师交谈后,我的重定向解决方案似乎是唯一可能的解决方案。
management.endpoints.web.base-path=/
management.endpoints.web.path-mapping.health=/
setting the base-path
to /
disables the discovery endpoint as per doc , 根据 doc将
base-path
设置为/
禁用发现端点,
When the management context path is set to /, the discovery page is disabled to prevent the possibility of a clash with other mappings.
当管理上下文路径设置为 / 时,发现页面被禁用以防止与其他映射发生冲突的可能性。
This allows you to set the path mapping for any single actuator endpoint to /
.这允许您将任何单个执行器端点的路径映射设置为
/
。 You might use it for health
, you might as well use it for any other one.您可以将它用于
health
,也可以将它用于任何其他方面。
Note this is only possible when base-path
is /
.请注意,这仅在
base-path
为/
时才有可能。 For any other base-path
, trying to do path-mapping
to /
for any of the endpoints will give you对于任何其他
base-path
,尝试对任何端点进行path-mapping
/
会给你
IllegalStateException: Ambiguous mapping. Cannot map 'Actuator root web endpoint' method
instead.反而。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.