Load custom starter properties files based on profile with spring boot v3.0 #37377
Labels
for: stackoverflow
A question that's better suited to stackoverflow.com
status: invalid
An issue that we don't feel is valid
With spring boot v2.3.4 I could use
ConfigFileApplicationListener
to load properties files from my custom starters by writing a environment post processor likeAnd then from each starter I could subclass this environment post processor like
This would result in properties being loaded appropriately i.e. if I ran the application that consumes this starter, with profile dev, then properties would be loaded from
my-starter.properties
,my-starter-dev.properties
,application.properties
andapplication-dev.properties
, where the first two come from the starter and the last 2 come from the consuming project.ConfigFileApplicationListener
has been removed in spring boot v3.0. The deprecation warning on the class suggests to useConfigDataEnvironmentPostProcessor
instead.After debugging I found that
StandardConfigDataLocationResolver
is used to resolve the properties files to be loaded. It constructs config file names likemeaning there isn't a way for me to inject my-starter config name here. I do not want the project that consumes the custom starters (there are multiple custom starters) to be aware of the config locations. Rather I want the auto configured custom starters to be responsible for loading the appropriate properties.
How can I achieve this in spring boot v3.0?
I have asked the question on the stackoverflow as well.
Trying here since I haven't had a response.
The text was updated successfully, but these errors were encountered: