LD is tigger forever,CG are not brothers forever, throw the pot and shine forever.
Modesty is not false, solid is not naive, treacherous but not deceitful, stay with good people, and stay away from poor people.
talk is cheap, show others the code and KPI, Keep progress,make a better result.
Survive during the day and develop at night。
@EnableScheduling
@SpringBootApplication(scanBasePackages = {
"com.alibaba.nacos.config.server",
"com.alibaba.nacos.core"})
public class Config {
public static void main(String[] args) {
SpringApplication.run(Config.class, args);
}
}
扫描底下的bean.
EnableScheduling定时调度:
先进入控制层:ConfigController:
按照这个为例:catalog在这里插入代码片
@GetMapping("/catalog")
@Secured(action = ActionTypes.READ, signType = SignType.CONFIG)
public RestResult<ConfigAdvanceInfo> getConfigAdvanceInfo(@RequestParam("dataId") String dataId,
@RequestParam("group") String group,
@RequestParam(value = "tenant", required = false, defaultValue = StringUtils.EMPTY) String tenant) {
ConfigAdvanceInfo configInfo = persistService.findConfigAdvanceInfo(dataId, group, tenant);
return RestResultUtils.success(configInfo);
}
前台传送一个dataId,group,tenant等。
调用:
ConfigAdvanceInfo configInfo = persistService.findConfigAdvanceInfo(dataId, group, tenant);在
ConfigAdvanceInfo findConfigAdvanceInfo(final String dataId, final String group, final String tenant);
看下接口的实现:
其中的一个实现:
@Override
public ConfigAdvanceInfo findConfigAdvanceInfo(final String dataId, final String group, final String tenant) {
final String tenantTmp = StringUtils.isBlank(tenant) ? StringUtils.EMPTY : tenant;
List<String> configTagList = this.selectTagByConfig(dataId, group, tenant);
ConfigAdvanceInfo configAdvance = databaseOperate.queryOne(
"SELECT gmt_create,gmt_modified,src_user,src_ip,c_desc,c_use,effect,type,c_schema FROM config_info WHERE data_id=? AND group_id=? AND tenant_id=?",
new Object[] {dataId, group, tenantTmp}, CONFIG_ADVANCE_INFO_ROW_MAPPER);
if (CollectionUtils.isNotEmpty(configTagList)) {
StringBuilder configTagsTmp = new StringBuilder();
for (String configTag : configTagList) {
if (configTagsTmp.length() == 0) {
configTagsTmp.append(configTag);
} else {
configTagsTmp.append(',').append(configTag);
}
}
configAdvance.setConfigTags(configTagsTmp.toString());
}
return configAdvance;
}
大概:
//首先进行的意思是:
1.根据dataid 参数
SELECT gmt_create,gmt_modified,src_user,src_ip,c_desc,c_use,effect,type,c_schema FROM config_info WHERE data_id=? AND group_id=? AND tenant_id=?"
查询有关配置信息:
2。将配置信息拼成一个字符串返回到控制层。
return RestResultUtils.success(configInfo);
其他的配置中心包含如下方法:
publishConfig,
getConfig,detailConfigInfo,deleteConfig,getConfigAdvanceInfo,listener,getListeners,等信息。
其他的模块架构也是如此,传统的Spring MVC 式样的请求和处理方式。
1.链接: link