配置文件
app-sync:#临时文件存放目录contentPath:./staticdec:121dataOfFile:111webToapp:#webToApp用户信息同步user:baseUrl:www.com.cmenable:truecron:0/5**?**getDir:/webToAppFile/userData/#webToApp单位信息同步unit:#webToApp单位同步数据接口baseUrl:www.com.cm#webToApp是否开启单位同步enable:true#webToApp当单位同步开启后每隔多长时间进行同步cron表达式cron:0/5**?**#webToApp当单位同步开启后文件夹存放目录getDir:/webToAppFile/unitData/all:#webToApp全表同步数据接口baseUrl:www.com.cm#webToApp是否开启全表同步enable:true#webToApp当全表同步开启后每隔多长时间进行同步cron表达式cron:0/5**?**#webToApp当全表同步开启后文件夹存放目录getDir:/webToAppFile/allDetailData/appToweb:#appToWeb用户信息同步user:#appToWeb用户同步数据接口baseUrl:www.com.cm#appToWeb是否开启用户同步enable:true#appToWeb当用户同步开启后文件夹存放目录getDir:/appToWebFile/userData/#appToWeb用户信息同步all:#appToWeb全表同步数据接口baseUrl:www.com.cm#appToWeb是否开启反馈同步enable:true#appToWeb当全表同步开启后每隔多长时间进行同步cron表达式cron:0/5**?**#appToWeb当全表同步开启后文件夹存放目录getDir:/appToWebFile/all/
获取方式
packagecom.common.utils;importorg.springframework.boot.context.properties.ConfigurationProperties;importorg.springframework.context.annotation.Configuration;@Configuration@ConfigurationProperties(prefix="app-sync")publicclassConfigYmlUtil{privateStringcontentPath;privateStringnumOfEncAndDec;privateStringdataOfFile;privatefinalWebToAppwebToapp=newWebToApp();privatefinalAppToWebappToweb=newAppToWeb();publicStringgetContentPath(){returncontentPath;}publicvoidsetContentPath(StringcontentPath){this.contentPath=contentPath;}publicStringgetNumOfEncAndDec(){returnnumOfEncAndDec;}publicvoidsetNumOfEncAndDec(StringnumOfEncAndDec){this.numOfEncAndDec=numOfEncAndDec;}publicStringgetDataOfFile(){returndataOfFile;}publicvoidsetDataOfFile(StringdataOfFile){this.dataOfFile=dataOfFile;}publicWebToAppgetWebToapp(){returnwebToapp;}publicAppToWebgetAppToweb(){returnappToweb;}/***webToApp*/publicstaticclassWebToApp{privatefinalBasePropertyuser=newBaseProperty();privatefinalBasePropertyunit=newBaseProperty();privatefinalBasePropertyall=newBaseProperty();publicBasePropertygetUser(){returnuser;}publicBasePropertygetUnit(){returnunit;}publicBasePropertygetAll(){returnallDetail;}}/***AppToWeb*/publicstaticclassAppToWeb{privatefinalBasePropertyuser=newBaseProperty();privatefinalBasePropertyall=newBaseProperty();publicBasePropertygetUser(){returnuser;}publicBasePropertygetAll(){returnall;}}/***基础集合属性*/publicstaticclassBaseProperty{privateStringbaseUrl;privateStringenable;privateStringcron;privateStringgetDir;publicStringgetBaseUrl(){returnbaseUrl;}publicvoidsetBaseUrl(StringbaseUrl){this.baseUrl=baseUrl;}publicStringgetEnable(){returnenable;}publicvoidsetEnable(Stringenable){this.enable=enable;}publicStringgetCron(){returncron;}publicvoidsetCron(Stringcron){this.cron=cron;}publicStringgetGetDir(){returngetDir;}publicvoidsetGetDir(StringgetDir){this.getDir=getDir;}}}
注意: 这种需要属性与集合定义的节点保持一致。