env的是:配置的树的属性源: ConfigTreePropertySource: 配置树的性的属性源文件: EnvironmentPostProcessor:环境配置后置处理器 EnvironmentPostProcessorApplicationListener: 处理环境的ApplcationListerner: EnvironmentPostProcessorsFactory:环境处理工厂: OriginTrackedMapPropertySource:原先的map属性源。 OriginTrackedPropertiesLoader:原先属性的加载器: OriginTrackedYamlLoader:原先的TrackerYaml加载器: PropertiesPropertySourceLoader:xml属性文件源文件加载器: PropertySourceLoader:属性源文件加载器: PropertySourceRuntimeHints: 属性源文件润赢得点击实现了RuntimeHintsRegistrar: RandomValuePropertySource:随机数值源文件: RandomValuePropertySourceEnvironmentPostProcessor:随机数值源文件处理器。 ReflectionEnvironmentPostProcessorsFactory:反射环境的后置处理器工厂:SpringApplicationJsonEnvironmentPostProcessor:Spring 应用程序JSON环境配置处理器: 其中yaml属性文件:处理器:
public class YamlPropertySourceLoader implements PropertySourceLoader {
@Override
public String[] getFileExtensions() {
return new String[] { "yml", "yaml" };
}
@Override
public List<PropertySource<?>> load(String name, Resource resource) throws IOException {
if (!ClassUtils.isPresent("org.yaml.snakeyaml.Yaml", getClass().getClassLoader())) {
throw new IllegalStateException(
"Attempted to load " + name + " but snakeyaml was not found on the classpath");
}
List<Map<String, Object>> loaded = new OriginTrackedYamlLoader(resource).load();
if (loaded.isEmpty()) {
return Collections.emptyList();
}
List<PropertySource<?>> propertySources = new ArrayList<>(loaded.size());
for (int i = 0; i < loaded.size(); i++) {
String documentNumber = (loaded.size() != 1) ? " (document #" + i + ")" : "";
propertySources.add(new OriginTrackedMapPropertySource(name + documentNumber,
Collections.unmodifiableMap(loaded.get(i)), true));
}
return propertySources;
}
}
|