I\'m using spring boot and application.properties
to select a database during development by @Configuration @Profile(\"dev\")
.
spri
I know you asked how to do this, but the answer is you should not do this.
Instead, have a application.properties
, application-default.properties
application-dev.properties
etc., and switch profiles via args to the JVM: e.g. -Dspring.profiles.active=dev
You can also override some things at test time using @TestPropertySource
Ideally everything should be in source control so that there are no surprises e.g. How do you know what properties are sitting there in your server location, and which ones are missing? What happens if developers introduce new things?
Spring Boot is already giving you enough ways to do this right.
https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html
The spring configuration precedence is as follows.
So your configuration will be overridden at the command-line if you wish to do that. But the recommendation is to avoid overriding, though you can use multiple profiles.