Reputation: 26914
Relevant similar (unanswered) question
I am having troubles implementing a simple configuration matrix for multi-tenant multi-environment Spring Boot application.
We have defined two sets of profiles: country_[iso2]
(the tenant!), e.g. country_uk
, country_ro
, country_de
; and the environment, development
, test
, qa
, prod
The thing is I now need to inject some URLs that depend/change according to the combination tenant and environment. A matrix configuration.
And since there is a large number of properties to set, I haven't been following the approach of the linked answer, instead I have created multiple dash-separated-name files
xx
share this)country_xx & development
)When I start the application with either country_xx
, development
, or the opposite, I don't get the value for the property I have set. I am using @ConfigurationProperties
.
In order not to end up with a huge single YAML file I don't like to merge every file into one and using the spring.profiles
key. I prefer separate files.
Am I missing something here?
Upvotes: 0
Views: 271
Reputation: 26914
This is not possible in Spring. Profiles are taken one at a time
private Set<StandardConfigDataReference> getProfileSpecificReferences(ConfigDataLocationResolverContext context,
ConfigDataLocation[] configDataLocations, Profiles profiles) {
Set<StandardConfigDataReference> references = new LinkedHashSet<>();
for (String profile : profiles) {
for (ConfigDataLocation configDataLocation : configDataLocations) {
String resourceLocation = getResourceLocation(context, configDataLocation);
references.addAll(getReferences(configDataLocation, resourceLocation, profile));
}
}
return references;
}
The above evaluates one profile at a time, not all the combinations
Upvotes: 0