I was dealing with a similar problem and I'd recommend using yaml configuration.
Let's describe .properties
file:
Initital approach
One can use it like this:
@Component
@PropertySources({
@PropertySource("classpath:application.properties"),
@PropertySource("classpath:application-${spring.profiles.active}.properties")
})
public class AppProperties {
}
This is very easy to configure. Limitation is, that you cannot combine profiles. I mean, that when you want to use profile as dev,local
where local
just alters some config properties for dev
profile, Spring will try to load application-dev,local.properties
file, which is very likely not what you want.
Btw, this is what Spring will do for you automatically, this is useful for topics as you described.
There is no way to configure it per profile (and not for whole list). Other possibility would be, that one can specify the list in spring.config.name
which is not the case at the moment.
Better approach
In short, use:
@Profile("dev")
@Configuration
@PropertySources({
@PropertySource("classpath:topic1-dev.properties"),
@PropertySource("classpath:topic2-dev.properties")
})
public class AppPropertiesDev {
}
Disadvantage is, you have to have several such config classes (dev, staging), but know you have the topics. Also you can use mutliple profiles, which are (as of my testing) loaded in order you specified. That way, your developer can easily use dev configuration and alter just what's needed for his/her testing.
Yaml approach
You can see the approach with yaml in question I asked earlier - Property resolving for multiple Spring profiles (yaml configuration), benefit is smaller amount of files - yaml has all the profiles in one file, which may or may not be what you want.