【发布时间】:2021-02-20 07:30:05
【问题描述】:
Spring Boot Actuator 不适用于 rest-full 应用程序,在浏览器上出现 Whitelabel 错误页面,在控制台日志中出现以下错误。
org.springframework.web.servlet.NoHandlerFoundException: No handler found for GET /actuator/health
在maven依赖下添加。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
Spring Boot 应用版本
<version>2.4.1</version>
在 application.properties 文件中添加属性
management.endpoints.enabled-by-default=true
management.endpoint.info.enabled=true
management.security.enabled=false
management.endpoints.web.exposure.include=*
spring.mvc.throw-exception-if-no-handler-found=true
无法使用以下 URL 访问执行器
http://localhost:8090/actuator/health
http://localhost:8090/actuator/
http://localhost:8090/health/
日志
WARN IN-WKS-435 [nio-8090-exec-1] o.s.w.s.PageNotFound : No mapping for GET /actuator/health
WARN IN-WKS-435 [nio-8090-exec-1] o.s.w.s.PageNotFound : No handler found for GET /actuator/health
WARN IN-WKS-435 [nio-8090-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.servlet.NoHandlerFoundException: No handler found for GET /actuator/health]
注意:除此之外,整个应用程序运行良好。
如果我需要在我们的应用程序中添加任何其他配置,请提出建议。
【问题讨论】:
-
请检查以下几点: 1. 属性中是否有
management.server.port配置值?它将更改执行器可访问的端口 2. 调用时的应用程序日志 - 查看是否没有错误 3. 在应用程序启动时,请检查日志行Exposing 14 endpoint(s) beneath base path '/actuator'- 仔细检查这些端点是否实际暴露。希望这有助于找出根本原因 -
@Daniel 感谢您的及时响应,在启动时我看不到在基本路径“/执行器”下暴露 14 个端点。我刚刚编辑了帖子并添加了日志。
-
你能在外部库中看到执行器吗?也许不知何故它没有正确添加@VivekJain
-
dextertron 我已验证,在类路径中可用。
标签: java spring spring-boot actuator