Merge branch '2.5.x' into main

Closes gh-28724
This commit is contained in:
Madhura Bhave
2021-11-17 16:41:23 -08:00
6 changed files with 197 additions and 22 deletions

View File

@@ -341,13 +341,24 @@ public class SpringApplication {
"Environment prefix cannot be set via properties.");
bindToSpringApplication(environment);
if (!this.isCustomEnvironment) {
environment = new EnvironmentConverter(getClassLoader()).convertEnvironmentIfNecessary(environment,
deduceEnvironmentClass());
environment = convertEnvironment(environment);
}
ConfigurationPropertySources.attach(environment);
return environment;
}
/**
* Convert the given {@link ConfigurableEnvironment environment} to an application
* environment that doesn't attempt to resolve profile properties directly.
* @param environment the environment to convert
* @return the converted environment
* @since 2.5.7
*/
public StandardEnvironment convertEnvironment(ConfigurableEnvironment environment) {
return new EnvironmentConverter(getClassLoader()).convertEnvironmentIfNecessary(environment,
deduceEnvironmentClass());
}
private Class<? extends StandardEnvironment> deduceEnvironmentClass() {
switch (this.webApplicationType) {
case SERVLET: