Java 即使在设置server.servlet.contextPath之后,弹簧执行器仍出现404未找到错误
我有一个spring批处理项目(使用Gradle)。我希望该项目与致动器集成 我已将此添加到gradle的导入中Java 即使在设置server.servlet.contextPath之后,弹簧执行器仍出现404未找到错误,java,spring,spring-boot,gradle,spring-boot-actuator,Java,Spring,Spring Boot,Gradle,Spring Boot Actuator,我有一个spring批处理项目(使用Gradle)。我希望该项目与致动器集成 我已将此添加到gradle的导入中 实现“org.springframework.boot:springbootstarteractuator” 在application.yaml中,我添加了 server: port: 8083 servlet: context-path: "/test" 现在,当我尝试点击-http://localhost:8083/test/health 在
实现“org.springframework.boot:springbootstarteractuator”
在application.yaml中,我添加了
server:
port: 8083
servlet:
context-path: "/test"
现在,当我尝试点击-http://localhost:8083/test/health
在我的本地服务器上,我收到错误消息-
{
"timestamp": "2020-09-21T18:36:42.779+00:00",
"status": 404,
"error": "Not Found",
"message": "",
"path": "/test/health"
}
在浏览器上运行相同的端点时,我看到此错误-
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Mon Sep 21 18:45:07 UTC 2020
There was an unexpected error (type=Not Found, status=404).
但是当我点击其他端点时,比如http://localhost:8083/nikhil/api/boot-应用程序
,它可以工作
有什么我不知道的地方吗
谢谢默认情况下,上下文路径为
/
,执行器端点为:
/actuator/health
/test/actuator/health
上下文路径设置为/test
,致动器端点为:
/actuator/health
/test/actuator/health
url的/exactor
部分来自management.endpoints.web.base path
属性。我想这就是你想要设定的:
management:
endpoints:
web:
base-path: /actuator
因此,如果您的配置是:
server:
port: 8083
servlet:
context-path: /
management:
endpoints:
web:
base-path: "/test"
您的致动器端点将是:
/test/health