英文:
Dedicated spring boot actuator URL
问题
Here is the translated content:
Context :
Spring Boot 2.7.4
Configuration tried (beyond several) :
management:
server:
port: 8080
endpoints:
web:
base-path: "/monitoring"
exposure:
include: "*"
server:
port: 8080
servlet:
context-path: /myapp
What I try to get :
获取两个不同的URL:
http://localhost:8080/myapp
返回 "hello world"
http://localhost:8080/monitoring
返回 actuator
What I get :
HTTP错误 401
我尝试了许多不同的配置,但我想知道我漏掉了什么。你知道问题在哪里吗?
英文:
Context :
Spring boot 2.7.4
Configuration tried (beyond several) :
management:
server:
port: 8080
endpoints:
web:
base-path: "/monitoring"
exposure:
include: "*"
server:
port: 8080
servlet:
context-path: /myapp
What I try to get :
get two different URL :
http://localhost:8080/myapp
returns "hello world"
http://localhost:8080/monitoring
returns actuator
What I get :
HTTP ERROR 401
I've tried so many different configurations, but I wonder what I missed. Do you know where is the problem ?
答案1
得分: 1
Actuator是应用程序的一部分,因此它位于与您在Spring应用程序之外定义的上下文相同的上下文中,现在可以在您的http://localhost:8080/myapp/monitoring
上运行。
要实现您想要的效果,您可以在控制器类中使用@RequestMapping("myapp")
,这样您的路径将会有前缀,并且可以将context-path
保留为/
(或从配置中省略它);
英文:
Actuator is part of the application, therfore it is in the same context which you define beyond spring app - servlet - and this now works for your http://localhost:8080/myapp/monitoring
To do what you want, you can for example, in controller classes you can use @RequestMapping("myapp")
to have your paths prefixed and leave context-path
as /
(or ommit it from your configuration);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论