mirror of
https://gitee.com/nutz/nutzboot.git
synced 2024-11-30 02:38:28 +08:00
- add: 增加Nacos配置项完整度判断,如果配置不完整,则跳过处理
This commit is contained in:
parent
212fb96dcd
commit
e9b8eecc76
@ -72,28 +72,32 @@ public class NacosConfigureStarter implements ServerFace {
|
||||
String group = conf.get(NACOS_GROUP);
|
||||
String dataType = conf.get(NACOS_DATA_TYPE);
|
||||
|
||||
Properties properties = new Properties();
|
||||
properties.put("serverAddr", serverAddr);
|
||||
ConfigService configService = NacosFactory.createConfigService(properties);
|
||||
String configInfo = configService.getConfig(dataId, group, 5000);
|
||||
log.debugf("get nacos config:%s", configInfo);
|
||||
if (Strings.isNotBlank(configInfo)) {
|
||||
setConfig(configInfo, dataType);
|
||||
}
|
||||
configService.addListener(dataId, group, new Listener() {
|
||||
@Override
|
||||
public void receiveConfigInfo(String configInfo) {
|
||||
log.debugf("receive nacos server config:%s", configInfo);
|
||||
if (Strings.isNotBlank(configInfo)) {
|
||||
setConfig(configInfo, dataType);
|
||||
if(Strings.isBlank(serverAddr) || Strings.isBlank(dataId) || Strings.isBlank(group) || Strings.isBlank(dataType)) {
|
||||
log.debugf("nacos server config is not found or incomplete, skip...");
|
||||
} else {
|
||||
Properties properties = new Properties();
|
||||
properties.put("serverAddr", serverAddr);
|
||||
ConfigService configService = NacosFactory.createConfigService(properties);
|
||||
String configInfo = configService.getConfig(dataId, group, 5000);
|
||||
log.debugf("get nacos config:%s", configInfo);
|
||||
if (Strings.isNotBlank(configInfo)) {
|
||||
setConfig(configInfo, dataType);
|
||||
}
|
||||
configService.addListener(dataId, group, new Listener() {
|
||||
@Override
|
||||
public void receiveConfigInfo(String configInfo) {
|
||||
log.debugf("receive nacos server config:%s", configInfo);
|
||||
if (Strings.isNotBlank(configInfo)) {
|
||||
setConfig(configInfo, dataType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getExecutor() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public Executor getExecutor() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void setConfig(String content, String contentType) {
|
||||
|
Loading…
Reference in New Issue
Block a user