在SpringApplication的启动的run方法中,有这么一个方法:
ConfigurableEnvironment environment = prepareEnvironment(listeners,
applicationArguments);
此方法是准备运行时的环境。这段代码的具体实现如下:
private ConfigurableEnvironment prepareEnvironment(
SpringApplicationRunListeners listeners,
ApplicationArguments applicationArguments) {
// Create and configure the environment
ConfigurableEnvironment environment = getOrCreateEnvironment();
configureEnvironment(environment, applicationArguments.getSourceArgs());
listeners.environmentPrepared(environment);
if (!this.webEnvironment) {
environment = new EnvironmentConverter(getClassLoader())
.convertToStandard