[英]Spring actuator giving 404 Not found error even after setting server.servlet.contextPath
I have a spring batch project (Using Gradle).我有一个 spring 批处理项目(使用 Gradle)。 I want to the project to be integrated with Actuator.
我希望该项目与 Actuator 集成。
I have added this to import to gradle implementation "org.springframework.boot:spring-boot-starter-actuator"
我已经添加了这个以导入到 gradle
implementation "org.springframework.boot:spring-boot-starter-actuator"
In application.yaml, I have added在 application.yaml 中,我添加了
server:
port: 8083
servlet:
context-path: "/test"
Now, when I try to hit - http://localhost:8083/test/health
on my local, I get error -现在,当我尝试在本地访问 -
http://localhost:8083/test/health
时,出现错误 -
{
"timestamp": "2020-09-21T18:36:42.779+00:00",
"status": 404,
"error": "Not Found",
"message": "",
"path": "/test/health"
}
On running the same endpoint on browser, I see this error-在浏览器上运行相同的端点时,我看到这个错误 -
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).
But when I hit other endpoints like http://localhost:8083/nikhil/api/boot-appliation
, it works!但是当我点击其他端点时,比如
http://localhost:8083/nikhil/api/boot-appliation
,它起作用了!
Any suggestions where I am missing?我缺少的任何建议?
Thanks谢谢
By default the context-path is /
, and the actuator endpoint is:默认情况下,上下文路径是
/
,执行器端点是:
/actuator/health
With the context-path set to /test
, the actuator endpoint is:上下文路径设置为
/test
时,执行器端点为:
/test/actuator/health
The /actuator
portion of the url is from management.endpoints.web.base-path
property. url 的
/actuator
部分来自management.endpoints.web.base-path
属性。 I think this is what you meant to set:我认为这就是您要设置的内容:
management:
endpoints:
web:
base-path: /actuator
So, all together, if your configuration is this:所以,总的来说,如果你的配置是这样的:
server:
port: 8083
servlet:
context-path: /
management:
endpoints:
web:
base-path: "/test"
Your actuator endpoint will be:您的执行器端点将是:
/test/health
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.