问题
I have a normal spring boot application, and two property files in resources
folder:
application.properties
com.example.prop1=value1
com.example.enableMock=true
application-dev.properties
com.example.prop1=value11
I have some logic based on whether com.example.enableMock
is present or missing. Problem is spring loads both files even if spring.profiles.active=dev
and the application is getting the com.example.enableMock
property.
How do I just load profile specific property file?
回答1:
By default application.properties
is loaded for any application-*.properties
because is shared by following way:
application.properties
- > application-dev.properties
- > application-test.properties
You can fix this if you put default
as profile.
Rename application.properties
to:
application-default.properties
来源:https://stackoverflow.com/questions/54191231/how-to-load-only-profile-specific-property-file-and-ignore-default-application-p