- spring.cloud.bootstrap.name默认为bootstrap
- spring.cloud.bootstrap.location默认为resources目录下 如果设置为config 这代表resources/config
- spring.cloud.config.allowOverride
如果想要远程配置优先级高,那么allowOverride设置为false,如果想要本地配置优先级高那么allowOverride设置为true
spring.cloud.config.allowOverride=true
- spring.cloud.config.overrideNone
overrideNone为true时本地配置优先级高,包括系统环境变量、本地配置文件等等
spring.cloud.config.overrideNone=true
- spring.cloud.config.overrideSystemProperties
只有系统环境变量或者系统属性才能覆盖远程配置文件的配置,本地配置文件中配置优先级低于远程配置
spring.cloud.config.overrideSystemProperties=true
@SpringBootConfiguration
public class KimServerApplication {
private static final String SPRING_CONFIG_NAME_KEY = "--spring.cloud.bootstrap.name";
private static final String DEFAULT_SPRING_CONFIG_PARAM = SPRING_CONFIG_NAME_KEY + "=" + "kim";
public static void main(String[] args) {
SpringApplication.run(KimServerApplication.class, updateArguments(args));
}
private static String[] updateArguments(String[] args) {
if (Arrays.stream(args).noneMatch(arg -> arg.startsWith(SPRING_CONFIG_NAME_KEY))) {
String[] modifiedArgs = new String[args.length + 1];
System.arraycopy(args, 0, modifiedArgs, 0, args.length);
modifiedArgs[args.length] = DEFAULT_SPRING_CONFIG_PARAM;
return modifiedArgs;
}
return args;
}
}