小编dev*_*ain的帖子

Spring Boot 执行器不工作 - Whitelabel 错误页面

Spring Boot Actuator不适用于完全休息的应用程序,在浏览器上出现 Whitelabel 错误页面,并在控制台日志中出现以下错误。

org.springframework.web.servlet.NoHandlerFoundException: No handler found for GET /actuator/health
Run Code Online (Sandbox Code Playgroud)

添加了以下 Maven 依赖项。

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)

我交叉检查,jar 文件在类路径中可用。在此输入图像描述

Spring Boot应用程序版本

<version>2.4.1</version>
Run Code Online (Sandbox Code Playgroud)

在 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
Run Code Online (Sandbox Code Playgroud)

无法使用以下 URL 访问执行器

http://localhost:8090/actuator/health
http://localhost:8090/actuator/
http://localhost:8090/health/
Run Code Online (Sandbox Code Playgroud)

日志

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]
Run Code Online (Sandbox Code Playgroud)

注意:除此之外,整个应用程序运行良好。

请建议我是否需要在我们的应用程序中添加任何其他配置。

java spring spring-boot spring-boot-actuator

5
推荐指数
1
解决办法
4866
查看次数

标签 统计

java ×1

spring ×1

spring-boot ×1

spring-boot-actuator ×1