When we deploy our application to the server, we will need to use a different set of configurations, such as the database's username, password, and URL, and so on. Spring Profiles provides a way to segregate the configuration for different environments.
We have the following environments for this:
- dev: The local development environment
- test: The unit test environment
- e2e: The end-to-end test environment
- staging: The staging environment
- production: The production environment
With Spring Profile, we can create a profile-specific configuration file, for example, the application-dev.properties file that we created for the local development environment, and, we use application.properties as the base configuration. Other configurations will override the defaults in the base configuration. For example, in our application.properties, we use <username> and ...