customizePropertySources method
Adds the sources a new environment starts with: the environment variables. Override it in a subclass that should always start with more sources.
It runs inside the constructor, before the subclass's own fields are initialized, so it must not use them.
class AppEnvironment extends StandardEnvironment {
@override
void customizePropertySources(MutablePropertySources sources) {
sources.addLast(MapPropertySource('defaults', {'port': '8080'}));
super.customizePropertySources(sources);
}
}
Implementation
void customizePropertySources(MutablePropertySources sources) {
sources.addLast(
SystemEnvironmentPropertySource(
SystemEnvironmentPropertySource.defaultName,
systemEnvironment,
),
);
}