SpringBoot 加载配置信息
2019-08-01 本文已影响14人
黄靠谱
SpringBoot 加载配置信息
可以结合actuator实现热加载配置,或者 nacos也可以
@ConfigurationProperties(prefix = "gateway.access-filter")
@RefreshScope
@Setter
@Getter
@Component("authConfig")
public class AuthConfig {
private List<AuthApp> apps;
private List<String> unCheckPathPatterns;
@Setter
@Getter
public static class AuthApp{
private String appType = "CCC";
private String appId;
private String secretKey;
private List<String> pathPatterns;//黑名单、白名单二选一
private List<String> channelId;//渠道id
private List<String> forbiddenPathPatterns;//地址
}
}
配置文件
gateway:
access-filter:
apps:
- appId: CC
appType: CCC
channelId:
- cc_dbc
- cc_webgl
forbiddenPathPatterns:
- ALL,/config/api/v2/internal/*/**
- ALL,/sheet/api/v2/internal/*/**
- ALL,/master/api/v2/internal/*/**
- ALL,/config/api/v2/mgnt/*/**
- ALL,/sheet/api/v2/mgnt/*/**
- ALL,/master/api/v2/mgnt/*/**
secretKey: jbY****3
- appId: CC2
appType: CCC
channelId:
- cc_dbc2
- cc_webgl2
forbiddenPathPatterns:
- ALL,/config/api/v2/internal/*/**
- ALL,/sheet/api/v2/internal/*/**
- ALL,/master/api/v2/internal/*/**
- ALL,/config/api/v2/mgnt/*/**
- ALL,/sheet/api/v2/mgnt/*/**
- ALL,/master/api/v2/mgnt/*/**
secretKey: JHFD^yB!
unCheckPathPatterns:
- ALL,/mp/*/adr/like/tplm
- ALL,/mp/*/adapter/kfm
- ALL,/mp/*/adapr/mp/tplmsg
- ALL,/mp/*/adapter/getn.json
- ALL,/mp/*/adaer/der/qrcode