spring boot base url
To set up a base URL in a Spring Boot application, follow these steps:
Open the
application.properties
file in your Spring Boot project. This file is typically located in thesrc/main/resources
directory.Add the following line to the
application.properties
file:server.servlet.context-path=/your-base-url
Replace/your-base-url
with the desired base URL for your application. For example, if you want the base URL to be/api
, you would write:server.servlet.context-path=/api
Save the
application.properties
file.Restart your Spring Boot application for the changes to take effect.
After following these steps, your Spring Boot application will now have a base URL that includes the specified path. For example, if you set the base URL to /api
, all endpoints in your application will be accessible via routes such as /api/some-endpoint
.
Note: It's important to remember that the base URL is relative to the application's context path, and it is used to group related endpoints together.