内蒙古高等级公路建设开发有限责任公司网站长春网站免费制作
ConfigDataLocationResolver接口方法说明
 isResolvable: 判断是否是需要转换的资源
 resolve: 将单个ConfigDataLocation转换为ConfigDataResource集合,在激活环境配置之前加载,也就是profile文件加载之前加载
 resolveProfileSpecific: 将单个ConfigDataLocation转换为ConfigDataResource集合,在加载环境配置时(Profiles)进行加载
 // 调用resolve将单个ConfigDataLocation转换为ConfigDataResource集合,并且加载文件内容
 org.springframework.boot.context.config.ConfigDataImporter#resolveAndLoad
ConfigDataLoader接口方法说明
 isLoadable: 是否获取符合条件的ConfigDataLoader
 load: 加载配置
ConfigDataResource抽象类:用来描述配置数据资源 optional: 表示是否有指定前缀标记
spring.main.cloud-platform: 配置cloud平台名称
 spring.config.name: 配置要加载配置文件的名称,默认值是["application"] org.springframework.boot.context.config.StandardConfigDataLocationResolver#CONFIG_NAME_PROPERTY
 spring.config.import、spring.config.additional-location、spring.config.location: 指定要加载的配置文件,优先级如下:
 spring.config.import 
 spring.config.additional-location
 spring.config.location
 可以配置多个,默认使用英文分号 ; 分割,也可以自定义解析器(ConfigDataLocationResolver)进行拆分,加载顺序按照拆分后的顺序进行加载,比如:
 spring.config.import=import.yaml;import2.yaml;import3.yaml
当配置了spring.config.location时,spring.config.name不生效
 当配置了spring.config.location时,默认的org.springframework.boot.context.config.ConfigDataEnvironment#DEFAULT_SEARCH_LOCATIONS不会再加载
 org.springframework.boot.context.config.ConfigDataEnvironment#DEFAULT_SEARCH_LOCATIONS包含:
 optional:classpath:/;optional:classpath:/config/ 和 optional:file:./;optional:file:./config/;optional:file:./config/*/
spring.config.on-not-found: 配置文件不存在时的策略,参考 org.springframework.boot.context.config.ConfigDataNotFoundAction 枚举类,可以通过SpringApplication.setDefaultProperties 进行设置
spring.profiles.include: 配置要加载的环境, 多个使用逗号分割  比如  a,b 是a和b两个环境
 spring.profiles.group: 配置的环境组  spring.profiles.group.x=d,f spring.profiles.group.y=e,g
 spring.profiles.active: 激活的环境  多个使用逗号分割  比如  a,b 是a和b两个环境
 spring.profiles.default: 默认加载的环境 多个使用逗号分割  比如  a,b 是a和b两个环境
 spring.profiles.include和spring.profiles.active都会放在spring.profiles.active集合中
 spring.profiles.active和spring.profiles.default同时配置时,默认使用spring.profiles.active,未配置spring.profiles.active时使用spring.profiles.default
profile: 控制拼接指定环境的配置文件,如 dev 生成的配置文件名称为 application-dev.yaml
在springboot中配置文件的加载顺序如下:
 yaml yml xml properties
 spring.config.name=application(默认配置)
 内部默认的配置文件加载顺序
 file:/application.yaml
 file:/application.yml
 file:/application.xml
 file:/application.properties
 file:./config/application.yaml
 file:./config/application.yml
 file:./config/application.xml
 file:./config/application.properties
 file:./config/*/application.yaml
 file:./config/*/application.yml
 file:./config/*/application.xml
 file:./config/*/application.properties
 classpath:/application.yaml
 classpath:/application.yml
 classpath:/application.xml
 classpath:/application.properties
 classpath:./config/application.yaml
 classpath:./config/application.yml
 classpath:./config/application.xml
 classpath:./config/application.properties
 // 默认是 profile是default
 file:/application-default.yaml
 file:/application-default.yml
 file:/application-default.xml
 file:/application-default.properties
 file:./config/application-default.yaml
 file:./config/application-default.yml
 file:./config/application-default.xml
 file:./config/application-default.properties
 file:./config/*/application-default.yaml
 file:./config/*/application-default.yml
 file:./config/*/application-default.xml
 file:./config/*/application-default.properties
  
