I am building an API using Spring Boot 2 (using Spring MVC) and it exposes endpoints such as /users
under the context path of /api
and a port of 8080. So I can access this by hitting http://localhost:8080/api/users
.
Now I would like to expose a separate set of auxiliary endpoints (similar to how Spring Boot actuator does) on a different port and context path. These endpoints would be implemented using Spring MVC as well. So for example, I expect a response when I hit http://localhost:9090/meta/status
where /meta
is the context path.
I've tried various approaches so far with not much success such as creating a separate dispatcher servlet, providing my own WebServerFactoryCustomizer
to adding a new Tomcat connector. All these approaches either override the original application's context path and port or do not recognise my meta endpoints at all.
If I could get some pointers on how to do this using Spring Boot 2 using purely Java config, it would help me a lot. Thanks.