Spring 引导 2 执行器 /health 和 /info returns HTTP 404
Spring Boot 2 Actuator /health and /info returns HTTP 404
我已将 pom.xml
中的依赖项添加到全新的 Spring 启动应用程序,如 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 响应。
我错过了什么吗?提前感谢您的帮助!
有两种可能的配置可以更改 Actuator /health 和 /info 端点:
首先,spring 启动 mvc 服务器,假设你有这样的:
server:
port: 8080
servlet:
context-path: /test
二、执行器管理服务器:
management:
server:
#port: #don't change it, then the port for actuator will be the same as server.port above
endpoints:
web:
base-path: /actuator #the default value for sring boot 2.x is /actuator, even you don't specify it, don't forget to include this in the URL
exposure:
include: "*"
endpoint:
health:
show-details: always
所以访问 Actuator 的权限 URL 应该是:
http://localhost:8080/test/actuator/info
http://localhost:8080/test/actuator/health
总的来说,访问Actuator端点的URL模式应该是:
http://localhost:{server.port}/{server.servlet.context-path}/{management.endpoints.web.base-path}/**
您可以将您的配置与此示例进行比较,以查看导致 404 错误的原因。
我已将 pom.xml
中的依赖项添加到全新的 Spring 启动应用程序,如 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 响应。
我错过了什么吗?提前感谢您的帮助!
有两种可能的配置可以更改 Actuator /health 和 /info 端点:
首先,spring 启动 mvc 服务器,假设你有这样的:
server:
port: 8080
servlet:
context-path: /test
二、执行器管理服务器:
management:
server:
#port: #don't change it, then the port for actuator will be the same as server.port above
endpoints:
web:
base-path: /actuator #the default value for sring boot 2.x is /actuator, even you don't specify it, don't forget to include this in the URL
exposure:
include: "*"
endpoint:
health:
show-details: always
所以访问 Actuator 的权限 URL 应该是:
http://localhost:8080/test/actuator/info
http://localhost:8080/test/actuator/health
总的来说,访问Actuator端点的URL模式应该是:
http://localhost:{server.port}/{server.servlet.context-path}/{management.endpoints.web.base-path}/**
您可以将您的配置与此示例进行比较,以查看导致 404 错误的原因。