r/SpringBoot • u/friscomatt • Jun 16 '26
Question application properties import and who wins
I'm running my application with profiles, like "dev" and have an application-dev.properties. If I use an import statement to pull in some shared properties across profiles I import it like so :
spring.config.import=classpath:application-shared.propertiesHowever, the properties from the imported application-shared.properties ALWAYS WIN.
Is there a way to "import" properties but still allow the active profile properties to override the imported properties?
4
Upvotes
1
u/Resident-Cow-7626 Jun 16 '26
Why would you want the imported properties to take a lower precedence over the non imported ones? Just remove the specific props from the imported configuration?
1
u/DominusEbad Jun 16 '26
Try
And make sure to only have that in your main application.properties file, not in a profile-specific properties file.
1
u/gdask Jun 16 '26
Extract the properties you have in the application yaml to a separate yaml and use the application yaml to import it after the shared properties one.
In a similar situation we decided it was cleaner this way.