当前位置: 首页 > news >正文

北京优化网站外包公司网站制作成本

北京优化网站外包公司,网站制作成本,住建部建设工程施工合同范本,网站的流程图Nacos当前命名空间下的配置文件需要跨命名空间读取其他配置文件的内容。可以先通过Nacos提供的API接口获取配置文件内容#xff0c;然后解析数据将其放入环境的PropertySource中。 相关依赖包 !-- Nacos依赖包 -- dependencygroupIdcom.alibaba.clo…Nacos当前命名空间下的配置文件需要跨命名空间读取其他配置文件的内容。可以先通过Nacos提供的API接口获取配置文件内容然后解析数据将其放入环境的PropertySource中。 相关依赖包 !-- Nacos依赖包 -- dependencygroupIdcom.alibaba.cloud/groupIdartifactIdspring-cloud-starter-alibaba-nacos-discovery/artifactIdversion2.2.6.RELEASE/versionexclusionsexclusiongroupIdcom.alibaba.nacos/groupIdartifactIdnacos-client/artifactId/exclusion/exclusions /dependencydependencygroupIdcom.alibaba.cloud/groupIdartifactIdspring-cloud-starter-alibaba-nacos-config/artifactIdversion2.2.6.RELEASE/versionexclusionsexclusiongroupIdcom.alibaba.nacos/groupIdartifactIdnacos-client/artifactId/exclusion/exclusions /dependencydependencygroupIdcom.alibaba.nacos/groupIdartifactIdnacos-client/artifactIdversion2.3.0/version /dependency部分代码 Order(Ordered.HIGHEST_PRECEDENCE) public class NacosEnvironmentPostProcessor implements EnvironmentPostProcessor {private static final String NACOS_PROPERTY_SOURCE_NAME NACOS;private static final String[] dataIds new String[]{db-sample.yml};private static final String LOGIN_URL http://$host/nacos/v1/auth/users/login;private static final String CONFIGS_URL http://$host/nacos/v1/cs/configs?dataIdgroupappNameconfig_tagspageNo1pageSize100tenant$tenantsearchbluraccessToken$accessToken;Overridepublic void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {if (environment instanceof StandardServletEnvironment || environment instanceof StandardReactiveWebEnvironment) {return;}addPropertySource(environment);}private void addPropertySource(ConfigurableEnvironment environment) {MapString, Object systemEnvironment environment.getSystemEnvironment();Object namespaceIdObj systemEnvironment.get(NACOS_NAMESPACE);if (null namespaceIdObj) {return;}String host String.valueOf(systemEnvironment.get(NACOS_HOST));String username String.valueOf(systemEnvironment.get(NACOS_USERNAME));String password String.valueOf(systemEnvironment.get(NACOS_PASSWORD));String group String.valueOf(systemEnvironment.get(NACOS_GROUP));String namespaceId String.valueOf(namespaceIdObj);log.info({} {} {} {} {}, host, username, password, group, namespaceId);processV2(environment, host, username, password, namespaceId);}private void processV1(ConfigurableEnvironment environment, String host, String username, String password,String namespaceId, String group) {NacosConfigProperties nacosConfigProperties new NacosConfigProperties();nacosConfigProperties.setEnvironment(new StandardEnvironment());nacosConfigProperties.setServerAddr(host);nacosConfigProperties.setUsername(username);nacosConfigProperties.setPassword(password);nacosConfigProperties.setNamespace(namespaceId);nacosConfigProperties.setGroup(group);ConfigService configService null;try {configService NacosFactory.createConfigService(nacosConfigProperties.assembleConfigServiceProperties());} catch (NacosException e) {log.error(e.getMessage(), e);}if (null configService) {return;}Properties properties new Properties();for (String dataId : dataIds) {addProperties(dataId, getPropertySources(configService, dataId, group), properties);}environment.getPropertySources().addFirst(new PropertiesPropertySource(NACOS_PROPERTY_SOURCE_NAME, properties));}private ListPropertySource? getPropertySources(ConfigService configService, String dataId, String group) {ListPropertySource? propertySources null;try {String config configService.getConfig(dataId, group, 10000);log.info({} {} config {}, dataId, group, config);propertySources NacosDataParserHandler.getInstance().parseNacosData(dataId, config, null);} catch (Exception e) {log.error(e.getMessage(), e);}return propertySources;}private void processV2(ConfigurableEnvironment environment, String host, String username, String password,String namespaceId) {if (null ! host host.contains(,)) {host host.split(,)[0];}MapString, String params new HashMap();params.put(username, username);params.put(password, password);String loginResp HttpClientUtils.sendPost(LOGIN_URL.replace($host, host), params, UTF-8);log.info(login response {}, loginResp);LoginDTO loginDTO JsonUtils.json(loginResp, LoginDTO.class);if (null loginDTO) {return;}String configsResp HttpClientUtils.sendGet(CONFIGS_URL.replace($host, host).replace($tenant, namespaceId).replace($accessToken, loginDTO.getAccessToken()), UTF-8);ConfigDTO configDTO JsonUtils.json(configsResp, ConfigDTO.class);if (null configDTO) {return;}ListConfigDTO.Item pageItems configDTO.getPageItems();if (null pageItems) {return;}Properties properties new Properties();pageItems.forEach(item - addProperties(item.getDataId(), getPropertySources(item), properties));environment.getPropertySources().addFirst(new PropertiesPropertySource(NACOS_PROPERTY_SOURCE_NAME, properties));}private ListPropertySource? getPropertySources(ConfigDTO.Item item) {ListPropertySource? propertySources null;try {propertySources NacosDataParserHandler.getInstance().parseNacosData(item.getDataId(), item.getContent(), null);} catch (Exception e) {log.error(e.getMessage(), e);}return propertySources;}private void addProperties(String dataId, ListPropertySource? propertySources, Properties properties) {if (null propertySources || propertySources.isEmpty()) {return;}propertySources.forEach(propertySource - {Object source propertySource.getSource();if (source instanceof Map) {MapString, Object map (Map) source;map.forEach((key, value) - {if (!key.equals(spring.application.name) !key.startsWith(server)) {int i dataId.lastIndexOf(.);if (i ! -1) {properties.setProperty(dataId.substring(0, i 1) key, String.valueOf(value));}}});}});}}
http://www.w-s-a.com/news/197409/

相关文章:

  • 移动端快速建站的方法青海公司网站建设
  • 网站重新搭建程序要多少钱移动互联网应用的使用情况
  • 学建站论坛给别人做网站怎么赚钱吗
  • 响应式网站代码校友会网站建设的目的
  • 北京公司网站网站建设html模板
  • 专门做医疗器械的网站免费网页制作系统团队
  • 网站开发技术 html临夏网站建设
  • flash网站模板免费下载拍卖网站开发多少钱
  • 北京网站建设制作颍州网站建设
  • 网站制作报价表做网站上海公司
  • 简洁大气蓝色文章资讯网站百度搜索广告推广
  • 河南建设工程协会网站网站收银系统建设
  • 网站制作 服务企业网站案例展示
  • 咸宁网站建设wordpress手动降级
  • 昆明做网站建设怎么样做网站赚钱全攻略
  • 企业网站建设实战教程微信如何注册小程序
  • 做一件代发网站百度seo服务
  • 小说网站开发 公司可以做行程的网站
  • 古交市网站建设公司apk连接wordpress
  • 网页 网 址网站区别wordpress菜单居右
  • 网站建设搭建运营一台云服务器做多个网站
  • 用php做网站用什么框架推广网站推荐
  • 如何用二级域名做网站多用户网上商城
  • 河南省建设科技网站浅谈电子商务网站建设与规划
  • 网站空间需要续费青海网站建设推广
  • 网站开发本地环境企业网站建设排名口碑
  • 做新闻的网站怎样赚钱个人网站课程设计报告
  • 网站设计样例那个网站做图片好看
  • 小型公司网站建设深圳网络营销策划有限公司
  • 国内优秀企业网站做视频网站用什么系统