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

个人做网站的必要性网站推广营销

个人做网站的必要性,网站推广营销,网页设计作业成品免费百度云,企业门户网站主要功能问题描述 在使用 Apollo Client 1.6.0 结合 Spring Cloud 的 RefreshScope 和 Value 注解时,遇到以下问题: 项目启动时第一次属性注入成功后续配置变更时,Value 属性会刷新,但总是刷新为第一次的旧值,而不是最新的配…

问题描述

在使用 Apollo Client 1.6.0 结合 Spring Cloud 的 @RefreshScope 和 @Value 注解时,遇到以下问题:

  • 项目启动时第一次属性注入成功
  • 后续配置变更时,@Value 属性会刷新,但总是刷新为第一次的旧值,而不是最新的配置值
<dependency><groupId>com.ctrip.framework.apollo</groupId><artifactId>apollo-client</artifactId><version>1.6.0</version>
</dependency>

问题本质深度解构

解决方案

apollo客户端升级到2.1.0

<dependency><groupId>com.ctrip.framework.apollo</groupId><artifactId>apollo-client</artifactId><version>2.1.0</version>
</dependency>

自定监听

import com.ctrip.framework.apollo.model.ConfigChange;
import com.ctrip.framework.apollo.model.ConfigChangeEvent;
import com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.cloud.context.environment.EnvironmentChangeEvent;
import org.springframework.cloud.context.scope.refresh.RefreshScope;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;@Component
@Slf4j
public class ApolloChangeListener implements ApplicationContextAware {private final RefreshScope refreshScope;private ApplicationContext applicationContext;public ApolloChangeListener(RefreshScope refreshScope) {this.refreshScope = refreshScope;}/*** 实时监听配置修改,并对修改项进行处理** @param changeEvent 配置修改事件(其中包含修改信息)*/@ApolloConfigChangeListener("${apollo.bootstrap.namespaces}")private void configChangeHandler(ConfigChangeEvent changeEvent) {log.info("================Apollo auto refresh start===========================");for (String changedKey : changeEvent.changedKeys()) {ConfigChange configChange = changeEvent.getChange(changedKey);String oldValue = configChange.getOldValue();String newValue = configChange.getNewValue();log.info("changedKey:{},oldValue:{}, newValue:{}", changedKey, oldValue, newValue);}refreshContext(changeEvent);log.info("================Apollo auto refresh end===========================");}/*** 跟进配置修改刷新上下文内容** @param changeEvent 配置修改事件(其中包含修改信息)*/public void refreshContext(ConfigChangeEvent changeEvent) {this.applicationContext.publishEvent(new EnvironmentChangeEvent(changeEvent.changedKeys()));refreshScope.refreshAll();}@Overridepublic void setApplicationContext(ApplicationContext applicationContext) throws BeansException {this.applicationContext = applicationContext;}
}
http://www.dtcms.com/wzjs/49651.html

相关文章:

  • 一个专业做设计的网站shodan搜索引擎
  • 蔷薇花园网站怎么做的网络营销的概述
  • 广州优质网站排名公司做任务赚佣金一单10块
  • 在线设计装修的网站河南郑州网站推广优化
  • wordpress中国网站排名手机百度引擎搜索入口
  • 小企业网站用什么主机好百度指数分析平台
  • logo是黑色 怎么调网站的色调网络推广公司官网
  • 邯郸网站设计 贝壳下拉推特最新消息今天
  • 石家庄网站建设培训班seo自然排名
  • 王悦做网站壹起航网络推广的目标
  • 医院网站和公众号建设方案手机优化助手
  • 网站里面的按钮链接怎么做网页链接
  • 网站浮标怎么做东莞关键词排名提升
  • 在百度做推广送网站好吗郑州seo顾问培训
  • 网站写动态新闻有什么好处微信公众号平台官网
  • seo网站内容优化手机导航下载2022新版
  • 怎样用自己的电脑做网站刷排名的软件是什么
  • 安徽电子学会网站建设搜索引擎优化的分类
  • wap手机网站线上渠道推广有哪些方式
  • 网站建设项目文档营销软件培训
  • 汕头汽配网站建设外贸建站推广公司
  • 多用户商城系统开发优化大师win10下载
  • 福步外贸网站网站seo服务公司
  • 济南专业做网站的公司网络推广公司经营范围
  • 做网站建设多少钱怎么做网站优化
  • 手机软件开发工具有哪些seo草根博客
  • 甘肃做网站哪家专业企业培训有哪些方面
  • 珠海建网站公司百度营销推广靠谱吗
  • 珠海市网站中国最新消息新闻
  • 学生管理系统网站此网站不支持下载视频怎么办