Reputation: 29577
Currently I can build my Gradle-based Spring Boot app like so:
./gradlew build && java -Dspring.config=. -jar build/libs/myapp.jar
And this works fine provided I have an application.yml
in the root of my project directory.
However, I would now like to have both an application-local.yml
as well as an application-dev.yml
, and to specify which one to use when I build + run myapp.jar
.
How can I specify either file at startup?
Upvotes: 0
Views: 98
Reputation: 2872
You can use Spring boot's capability of using Profile Specific property file. You can specify the application yml inline with your profile name application-[profile].yml. In your case, it would be
application-dev.yml
application-local.yml
Specify the profile you would want to use as a command line argument
-Dspring.profiles.active=dev
Upvotes: 1