You can have a property declared in your application.properties as
spring.profiles.active=dev
test.url=${TEST_URL}
then create different configuration properties files based on your environment such as application-dev.properties
or application-prod.properties
and define TEST_URL
in this files
application-dev.properties
TEST_URL=some_test_url_for_dev
application-prod.properties
TEST_URL=some_test_url_for_prod
Spring Boot has inbuilt support for the environment or profile-specific Application Properties. That means we can have multiple application properties , and Spring will refer to the file that applies to the currently active profile.
The default properties file in a Spring Boot application is ‘application.properties‘. In addition, we can have profile-specific properties that follow the naming pattern – application-{spring.profiles.active}.properties
. such as application-dev.properties
You can check spring profiles documentation spring profile documentation