how to set context path in spring boot

Setting Context Path in Spring Boot

To set the context path in Spring Boot, follow these steps:

  1. Update or application.yml file:
  2. Open the or application.yml file in your Spring Boot project.
  3. Add the following line to set the context path:
    • For server.servlet.context-path=/yourContextPath
    • For application.yml: yaml server: servlet: context-path: /yourContextPath


  1. Restart the Application:
  2. After making the changes, restart your Spring Boot application for the new context path to take effect.


  1. Verify the Context Path:
  2. Once the application is restarted, verify the context path by accessing the application using the new context path in the URL.


By following these steps, you can easily set the context path in your Spring Boot application.