PropertySourcesPropertyResolver
SpringBoot应用中涉及配置相关的东西,例如配置文件、环境变量、系统变量等都是基于类ApplicationServletEnvironment的构造器开启的,如下其抽象父类AbstractEnvironment构造器:
public abstract class AbstractEnvironment{
private final MutablePropertySources propertySources;
private final ConfigurablePropertyResolver propertyResolver;
public AbstractEnvironment() {
this(new MutablePropertySources());
}
protected AbstractEnvironment(MutablePropertySources propertySources) {
this.propertySources = propertySources;
this.propertyResolver = createPropertyResolver(propertySources);
customizePropertySources(propertySources);
}
}
抽象类PropertySource 内部存在两个属性 name & source:
public abstract class PropertySource<T> {
protected final String name;
protected final T source;
}
其中,泛型source是指压缩后的不同类型的配置value。
抽象类PropertySource的常用子类如下所示:
原文地址:https://blog.csdn.net/qq_36851469/article/details/140386956
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!