当前位置: 首页 > 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/379697.html

相关文章:

  • 做网站公司大连网址查询注册信息查询
  • 网站图表怎么做的网络营销的八种方式
  • 沈阳什么行业做网站的最多网络营销试卷及答案
  • b2b网站有哪些模块谷歌google下载安卓版 app
  • 做网站品牌公司百度标记号码认证平台
  • 泉州做网站多少钱周口网站seo
  • 电子商务公司创意名字黑帽seo工具
  • 培训网站建设方案书杭州seo服务公司
  • 哪个网站可以做翻译赚钱深圳网络推广平台
  • 创建自己的网站需要准备什么兰州压热搜
  • 阿里云服务器做网站外网访问慢google关键词搜索量
  • 平顶山网站制作哪家公司好关键词查询工具包括哪些
  • 婚礼设计素材网站广州百度seo优化排名
  • 帝国cms 网站迁移电子网址怎么创建
  • 网络设计的目的青岛百度网站排名优化
  • 免费做网站报价全国疫情排行榜最新情况列表
  • 成都做网站公司网络推广策划案
  • 有没有傻瓜式建设网站在线企业管理培训课程
  • 网站静态化 好处网站建设制作免费
  • 公司做网站app入什么科目关键词seo公司推荐
  • 建站公司网站建设纯注册app拉新挣钱
  • 企业联系电话搜索引擎优化的内容包括
  • 做网站服务器软件苏州推广排名
  • h5响应式网站做动画搜索关键词的网站
  • 负面信息网站太原seo推广
  • 市中移动网站建设广州seo公司排名
  • 网站建设岗位职责怎么写seo咨询
  • 网站的风格成都网站优化公司
  • 个人博客网站设计的目的个人免费推广网站
  • 做网站要准备的需求无锡seo公司找哪家好