Search in sources :

Example 1 with NacosConfigProperties

use of com.alibaba.cloud.nacos.NacosConfigProperties in project muses by acgist.

the class MusesConfigBuilder method build.

/**
 * 创建系统配置
 *
 * @return
 */
public MusesConfig build() {
    final ConfigService configService = this.nacosConfigManager.getConfigService();
    final NacosConfigProperties nacosConfigProperties = this.nacosConfigManager.getNacosConfigProperties();
    try {
        // 保存配置中心
        configService.publishConfig(MusesConfig.MUSES_CONFIG, nacosConfigProperties.getGroup(), JSONUtils.toJSON(this.musesConfig));
    } catch (NacosException e) {
        log.error("设置系统配置异常", e);
    }
    return this.musesConfig;
}
Also used : ConfigService(com.alibaba.nacos.api.config.ConfigService) NacosConfigProperties(com.alibaba.cloud.nacos.NacosConfigProperties) NacosException(com.alibaba.nacos.api.exception.NacosException)

Example 2 with NacosConfigProperties

use of com.alibaba.cloud.nacos.NacosConfigProperties in project muses by acgist.

the class MusesConfigBuilder method init.

/**
 * 初始系统配置
 *
 * @param nacosConfigManager NacosConfigManager
 *
 * @return this
 */
private MusesConfigBuilder init() {
    final ConfigService configService = this.nacosConfigManager.getConfigService();
    final NacosConfigProperties nacosConfigProperties = this.nacosConfigManager.getNacosConfigProperties();
    try {
        final String oldConfig = configService.getConfig(MusesConfig.MUSES_CONFIG, nacosConfigProperties.getGroup(), MusesConfig.TIMEOUT);
        if (StringUtils.isEmpty(oldConfig)) {
            this.musesConfig = new MusesConfig();
        } else {
            this.musesConfig = JSONUtils.toJava(oldConfig, MusesConfig.class);
        }
    } catch (NacosException e) {
        log.error("初始系统配置异常", e);
    }
    return this;
}
Also used : ConfigService(com.alibaba.nacos.api.config.ConfigService) NacosConfigProperties(com.alibaba.cloud.nacos.NacosConfigProperties) NacosException(com.alibaba.nacos.api.exception.NacosException)

Aggregations

NacosConfigProperties (com.alibaba.cloud.nacos.NacosConfigProperties)2 ConfigService (com.alibaba.nacos.api.config.ConfigService)2 NacosException (com.alibaba.nacos.api.exception.NacosException)2