【发布时间】:2020-03-06 14:51:06
【问题描述】:
我正在使用 Spring Actuator(版本 2.2.4.RELEASE)在 /localhost:8080/my-app/actuator/health 处生成运行正常的健康检查端点。
这会生成 3 个端点,在访问 /actuator 时显示并在 Swagger(版本 2)中显示:
/actuator/health-
/actuator/health/{*path}(在我的招摇页面中,这显示为/actuator/health/**) /actuator/info
由于 AWS 的原因,我在使用 health/** 时遇到了问题,我想删除它(我也想删除 /info,因为我不需要它)。
我已尝试将以下内容添加到我的 application.properties 文件中:
management.endpoints.web.exposure.exclude=health,info
和
management.endpoints.jmx.exposure.exclude=health,info
但它没有任何区别(它们仍然会生成)。我尝试使用* 来查看是否会强制所有端点消失,但它也不会改变任何东西。
知道如何解决这个问题吗?
编辑 1
我发现一个属性文件被另一个文件覆盖。因此,使用以下命令:
management.endpoints.enabled-by-default=false
management.endpoint.health.enabled=true
摆脱/actuator/info 端点。但是,我仍然需要摆脱 /actuator/health/{*path} 并保留 /actuator/health 端点。
【问题讨论】:
-
在我的情况下,
management.endpoints.web.exposure.exclude=health,info禁用了 Web 端点和 swagger 条目。您是否确认没有更高优先级的外部配置覆盖您的application.properties?对于所有财产来源,请查看docs.spring.io/spring-boot/docs/current/reference/html/… -
@Lesiak 我已经解决了覆盖属性的问题。但是,仍然存在一个问题。我已经详细编辑了我的答案。
标签: spring-boot swagger spring-boot-actuator