在Spring Boot项目中集成Actuator之后,可以正常访问/actuator跟/actuator/health,但访问其他路径会出现404问题。

Spring Boot Actuator访问/actuator路径404错误插图
actuator 404

导致这个问题的主要原因是对应的路径默认没有开启,正常情况下/actuator/health和/actuator/info 对应的路径是模式开启的,而其他的端点却不是。

也可以通过访问http://localhost:8080/actuator来查看默认开启了哪些端点。

Spring Boot Actuator访问/actuator路径404错误插图1

如果需要开启其他的端点,可以在配置文件中进行配置,比如开启所有端点:

management.endpoints.web.exposure.include="*"

开启指定端点:

management.endpoints.web.exposure.include=restart,pause,shutdown


Spring Boot Actuator访问/actuator路径404错误插图2

关注公众号:程序新视界,一个让你软实力、硬技术同步提升的平台

除非注明,否则均为程序新视界原创文章,转载必须以链接形式标明本文链接

本文链接:http://www.choupangxia.com/2021/07/06/spring-boot-actuator-404/