2. Different ways to change the context path

server.context-path is properties using that application context path can be changed.

application.properties

server.context-path=/demo

application.yml

server:
context-path: /demo

Example:

http://localhost:8282/demo/hello.html

2. Context path using the command line arguments

Another way is to change context path using command line argument while staring application at that time pass JVM arguments like : -Dserver.contextPath. It will be useful if don’t want to hardcode context path in the application.

Example:

http://localhost:8282/demo/hello.html

3. Conclusion

In this article, We learn about how to change context path in spring boot application sometimes developer forgot to add context path in URL and getting 404 page while configuring application which is developed by other developers so make sure that if context path is specified in the application then URL must start with the context path.

JavaDeveloperZone is the group of innovative software developers. We are expert in Java JEE and BigData application development. Our contributions will help Java developers and make development journey easy. Feel free to ask any question and suggestion. Always have space for improvement !
We are also providing software application development as service. Contact us