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

如何建单页网站栏目百度浏览器电脑版

如何建单页网站栏目,百度浏览器电脑版,网站里滚动的图片怎么做的,知乎 拒绝 朋友 做网站Nacos当前命名空间下的配置文件需要跨命名空间读取其他配置文件的内容。可以先通过Nacos提供的API接口获取配置文件内容&#xff0c;然后解析数据将其放入环境的PropertySource中。 相关依赖包 <!-- Nacos依赖包 --> <dependency><groupId>com.alibaba.clo…
Nacos当前命名空间下的配置文件需要跨命名空间读取其他配置文件的内容。可以先通过Nacos提供的API接口获取配置文件内容,然后解析数据将其放入环境的PropertySource中。
  • 相关依赖包
<!-- Nacos依赖包 -->
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId><version>2.2.6.RELEASE</version><exclusions><exclusion><groupId>com.alibaba.nacos</groupId><artifactId>nacos-client</artifactId></exclusion></exclusions>
</dependency><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId><version>2.2.6.RELEASE</version><exclusions><exclusion><groupId>com.alibaba.nacos</groupId><artifactId>nacos-client</artifactId></exclusion></exclusions>
</dependency><dependency><groupId>com.alibaba.nacos</groupId><artifactId>nacos-client</artifactId><version>2.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?dataId=&group=&appName=&config_tags=&pageNo=1&pageSize=100&tenant=$tenant&search=blur&accessToken=$accessToken";@Overridepublic void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {if (environment instanceof StandardServletEnvironment || environment instanceof StandardReactiveWebEnvironment) {return;}addPropertySource(environment);}private void addPropertySource(ConfigurableEnvironment environment) {Map<String, 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 List<PropertySource<?>> getPropertySources(ConfigService configService, String dataId, String group) {List<PropertySource<?>> 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];}Map<String, 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;}List<ConfigDTO.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 List<PropertySource<?>> getPropertySources(ConfigDTO.Item item) {List<PropertySource<?>> 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, List<PropertySource<?>> propertySources, Properties properties) {if (null == propertySources || propertySources.isEmpty()) {return;}propertySources.forEach(propertySource -> {Object source = propertySource.getSource();if (source instanceof Map) {Map<String, 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.hkea.cn/news/11386/

相关文章:

  • 淘宝网页版电脑版入口老铁seo外链工具
  • 西安那里做网站百度关键词优化首选667seo
  • 浏览收费网站模板营销型网站的类型有哪些
  • 旅游网站的功能结构图seo手机优化软件哪个好用
  • 官方网站哪家做的最好服务器ip域名解析
  • 网站建设做什么费用乐天seo培训
  • 找人做网站!!! 网站定制开发福建seo网站
  • 网站建设的认可搜索引擎优化培训免费咨询
  • 网罗天下做网站靠谱吗网络广告设计
  • wordpress 指定审核人南昌seo排名扣费
  • 南通网站建设系统电话优化网站排名方法
  • dede中英文企业网站学习软件的网站
  • 石家庄疫情最新情况最新消息seo标题优化
  • 淘宝做轮播广告哪个网站好永久免费google搜索引擎
  • 曰本免费网站文军seo
  • 项目计划书目录徐州网站建设方案优化
  • 创新的邯郸网站建设页面设计漂亮的网站
  • 怎样建设个人影视网站公司seo排名优化
  • wordpress全站加密免费手机网站建站系统
  • 织梦可以做哪些类型型网站整合营销传播策略
  • 软件库网站源码竞价托管外包服务
  • 网站建设概况培训网络营销机构
  • 最近播放中文版在线观看电视剧上海优化关键词的公司
  • 淘宝官网首页登录注册长沙seo行者seo09
  • 建站公司网站建设武汉做seo
  • 百度网站推广网络网络推广深圳有效渠道
  • 邵阳网站建设公司中国进入全国紧急状态
  • 信息图表设计网站痘痘怎么去除有效果
  • 网站的域名在哪里看互联网推广是什么工作内容
  • 用手机做自己的网站怎么申请网站详细步骤