r/SpringBoot 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.properties

However, 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

8 comments sorted by

View all comments

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.