【发布时间】:2020-09-11 13:05:31
【问题描述】:
我已将 pom.xml 中的依赖项添加到全新的 Spring Boot 应用程序中,如 Spring documentation 中所述
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
并将以下属性添加到 application.yml 以便仅公开 /health 和 /info 端点
management:
endpoints:
web:
exposure:
include:
- info
- health
jmx:
exposure:
exclude: "*"
endpoint:
info:
enabled: true
health:
enabled: true
但无法通过 localhost:8080/health 和 localhost:8080/info 到达运行应用程序时提到的端点 - 有 HTTP 404 响应。
我错过了什么吗?提前感谢您的帮助!
【问题讨论】:
-
如果您的应用程序在
localhost:8080/(无上下文路径)上运行,它应该可以工作/很难说,缺少什么...配置匹配默认值/可以省略,除了@ 987654333@ 部分,这似乎也不好缩进(至少在帖子中)。 -
@RebaiAhmed 你说的很对!最后,我在spring.io/guides/gs/actuator-service 找到了它。如果您愿意 - 在单独的答案中指定它,以便我可以标记为解决方案,否则我将自己回答。谢谢!
-
你可以让它成为你的答案:) @DmitryAdonin
标签: java spring spring-boot spring-boot-actuator