问题
I am working on a spring-boot application, I need your assistance on below scenario.
I have properties files for each environment something like application-dev.properties, application-prod.properties etc. Is there way that my application can load environment specific properties file by using spring @Profile annotation.
Please help.
回答1:
You don't need to use @Profiles
annotation at all. Just use
@ConfigurationProperties(locations = "classpath:myapp-${environment.type}.properties")
and define environment type via system property. E.g. via command line -Denvironment.type=dev
.
来源:https://stackoverflow.com/questions/34394054/loading-environment-specific-properties-file-in-spring