Reputation: 8605
Is there any advantage using a custom context-path instead of root context for Spring Boot applications?
Many microservices are accessed without a custom context-path in the url, and another ones does not.
As Spring Boot initially loads only one web container we would not have the same behavior that a Tomcat offers, when we have many web applications running into the same http port.
What are differences for both cases in this kind of architecture?
Upvotes: 2
Views: 1882
Reputation: 7868
Providing a custom context path makes your service more reusable. If you choose the default context "/" then you are more likely to have a collision with another service that attempts to use the context as compared to a custom one. Not to mention, it makes it more human readable and intuitive as to what the service is for (IMO).
Basically you stated it yourself. If you intend to run multiple services on the same physical server, you would have to alter the Tomcat port for each Spring Boot application (assuming you are using embedded Tomcat). If you were not using embedded tomcat, you would have even more fun by having multiple installations of Tomcat on the same server, each with a different port.
Granted, you could make the decision that you will run only one application per physical server and use DNS to provide a nice URL path, that would be mapped to a specific server IP. That would avoid the conflict, but seems very wasteful of resources and is harder to maintain.
Upvotes: 2