Reputation: 168
I was looking at a way to configure different application.properties file depending on a JVM environnement variable.
I found this documentation on Spring references.
In addition to application.properties files, profile-specific properties can also be defined using the naming convention application-{profile}.properties.
Profile specific properties are loaded from the same locations as standard application.properties, with profile-specific files always overriding the default ones irrespective of whether the profile-specific files are inside or outside your packaged jar.
Then I did that :
And then added a -Dspring.profiles.active=dev
to my JVM options.
I tried to see that my params in dev are used but it isn't the case. Te application loads the data from the application.properties
file.
Any idea why?
Upvotes: 3
Views: 1963
Reputation: 304
Try to modify the default properties file's name to 'application-default.properties', as it is said in the documentation:
The Environment has a set of default profiles (by default [default]) which are used if no active profiles are set (i.e. if no profiles are explicitly activated then properties from application-default.properties are loaded).
Upvotes: 3