6

I am running my springboot application by setting context-path to /myservice. This results into appending all my actuator endpoints exposed at the URL- http://localhost:8080/myservice/actuator/, while I want only http://localhost:8080/actuator/. Is there a way to tell the springboot to ignore appending context path to actuator endpoints (through DispatcherServlet or CXFServlet or anything) Please help.

Jonas
  • 121,568
  • 97
  • 310
  • 388

2 Answers2

7

Unfortunately this is not possible.

From the documentation:

Unless the management port has been configured to expose endpoints by using a different HTTP port, management.endpoints.web.base-path is relative to server.servlet.context-path (Servlet web applications) or spring.webflux.base-path (reactive web applications). If management.server.port is configured, management.endpoints.web.base-path is relative to management.server.base-path.

Source: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#actuator.monitoring.customizing-management-server-context-path

What you could do is to use a different port for the management endpoints.

management.server.port=8081

Then you will get http://localhost:8081/actuator

Simon Martinelli
  • 34,053
  • 5
  • 48
  • 82
3

Technically it is not possible because spring boot has only one DispatcherServlet which is a front controller, if you want two different paths then you can use @RequestMapping annotation on two different controllers`

Still of you want two different context-paths then you should have two DispatcherServlet's

Zaur
  • 206
  • 2
  • 4