spring启动执行器不工作-whitelabel错误页

yjghlzjz  于 2021-07-23  发布在  Java
关注(0)|答案(1)|浏览(405)

SpringBootActuator对于rest完整应用程序不起作用,正在获取浏览器上的白标签错误页以及控制台日志中的错误下方。

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]

注意:除此之外,整个应用程序运行良好。
如果我需要在我们的应用程序中添加任何额外的配置,请提出建议。

6psbrbz9

6psbrbz91#

如果在ide(intellij或eclipse)中运行,则无法获取spring引导执行器终结点。
我试着在cmd上使用below命令(在ide之外)运行jar,它对我很有用。 c:\workspace\demo\target\java -jar demo-spring-boot-project.jar 我可以访问下面的网址
http://localhost:8090/致动器/健康

相关问题