Support profile specific ConfigData imports
Update the `ConfigData` import support to allow individual property sources to be imported with a higher precedence than profile specific imports. Prior to this commit, imported sources would always have a higher precedence than the file that imported them, but a lower precedence than any profile-specific variant of the same file. For example, given an `application.properties` that imports `myconfig`, the contributor tree would be as follows: ROOT +- `application.properties` | +- myconfig +- `application-<profile>.properties` The precedence would be: 1) `application-<profile>.properties` 2) myconfig 3) `application.properties` This works well for most situations, but can be confusing if import is for a profile-specific property source. For example: ROOT +- `application.properties` | +- myconfig | +- myconfig-<profile> +- `application-<profile>.properties` Results in the order precedence of: 1) `application-<profile>.properties` 2) myconfig-<profile> 3) myconfig 4) `application.properties` This means that whilst `myconfig` overrides `application.properties`, `myconfig-profile` does not override `application-<profile>.properties`. For this specific situation, the preferable order would be: 1) myconfig-<profile> 2) `application-<profile>.properties` 3) myconfig 4) `application.properties` To support this alternative ordering a new `PROFILE_SPECIFIC` config data option has been added. Additionally, options may now be specified on a per-source basis by using the `PropertySourceOptions` interface. Fixes gh-25766
Showing
This diff is collapsed.
Please register or sign in to comment