Change context path in a Spring MVC application + Tomcat

52 views Asked by At

We have a webservice developed as a Spring MVC application, released as myapp.war, and deployed in Tomcat to some URL http://example.com/myapp.

Now, we think that it would be more nice to change the context path to something like http://example.com/myapp/api/v1.

Of course, a simple solution is to change all controllers from @RequestMapping("/") to @RequestMapping("/api/v1"). IMHO this is a bad solution because the prefix should not be part of the endpoint URLs (according to OpenAPI specifications).

So we ask if this is possible without modifying all endpoints and without modifying Tomcat's configuration.

Please notice that this question has nothing to do with Spring Boot!

Thank you.

0

There are 0 answers