java Spring Boot 2 健康执行器默认映射

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46363975/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 09:10:48  来源:igfitidea点击:

Spring Boot 2 health actuator default mapping

javaspringspring-bootspring-boot-actuator

提问by Boni García

I'm using Spring Boot 2 M3 actuators. By default, the health endpoint is mapped to /application/health.

我正在使用 Spring Boot 2 M3 执行器。默认情况下,健康端点映射到/application/health.

  • Is it possible to change this path to /health?
  • 是否可以将此路径更改为/health

采纳答案by Darren Forsythe

See this documentation for Spring Boot 2.0.0,

请参阅 Spring Boot 2.0.0 的此文档,

https://docs.spring.io/spring-boot/docs/2.0.0.M4/reference/htmlsingle/#production-ready-customizing-management-server-context-path

https://docs.spring.io/spring-boot/docs/2.0.0.M4/reference/htmlsingle/#production-ready-customizing-management-server-context-path

the property is,

该物业是,

management.context-path

management.context-path

I think this should work but cannot verify it right now. management.context-path=/

我认为这应该有效,但现在无法验证。 management.context-path=/

回答by Sophia Price

In your application.properties file add this to set the base path to '/'

在您的 application.properties 文件中添加此项以将基本路径设置为“/”

management.endpoints.web.base-path=/

Path will now be '/health'

路径现在将是'/health'

Edit: Alternatively if you are using YAML use:

编辑:或者,如果您使用的是 YAML,请使用:

management:
  endpoints:
    web:
      base-path: /

回答by Taylor Gautier

FYI as of Spring Boot 2.0.0.RELEASE the default health endpoint is /actuator/health

仅供参考,从 Spring Boot 2.0.0.RELEASE 开始,默认的健康端点是 /actuator/health

回答by egorlitvinenko

Yes, it is endpoints.health.path.

是的,它是endpoints.health.path

Update

更新

Sorry, I understood like you want to change health to something else.

抱歉,我理解您想将健康更改为其他内容。

If you want change /application/health to /health, then you should use endpoints.jmx.domain. Or change path of your application to ROOT.

如果要将 /application/health 更改为 /health,则应使用endpoints.jmx.domain. 或者将您的应用程序路径更改为 ROOT。

See