Disconf

修改点

把ReloadingPropertyPlaceholderConfigurer类改为继承PropertySourcesPlaceholderConfigurer

注意事项

不要再使用@PropertySource注解来引入本地配置文件

不要再使用其他PropertyPlaceholderConfigurer来引入本地配置文件

不要再使用其他PropertySourcesPlaceholderConfigurer来引入本地配置文件

demo

springboot1、2按如下进行注解式配置:

@Configuration

@EnableAspectJAutoProxy(proxyTargetClass = true)

public class ApplicationConfig {

@Bean(destroyMethod = "destroy")

public BeanDefinitionRegistryPostProcessor disconfMgrBean() {

return new DisconfMgrBean();

}

@Bean(initMethod = "init", destroyMethod = "destroy")

public DisconfMgrBeanSecond disconfMgrBeanSecond() {

return new DisconfMgrBeanSecond();

}

@Bean

@Primary

public PropertiesFactoryBean propertiesFactory() throws IOException {

ReloadablePropertiesFactoryBean factory = new ReloadablePropertiesFactoryBean();

/*

* 本地文件路径("classpath:/test.properties")放前面,远程文件名放后;这样远程文件的内容会覆盖本地文件的内容。

* 需要配置-Ddisconf.ignore=test.properties,以避免disconf尝试从远程下载test.properties文件

*/

factory.setLocations(Arrays.asList("classpath:/test.properties", "db.properties", "dubbo.properties"));

factory.setFileEncoding(StandardCharsets.UTF_8.name());

return factory;

}

@Bean

public static PropertySourcesPlaceholderConfigurer properties(PropertiesFactoryBean factory) throws IOException {

ReloadingPropertyPlaceholderConfigurer ppc = new ReloadingPropertyPlaceholderConfigurer();

// 如果需要远程内容覆盖本地application.properties里的内容,需设置localOverride为true

// ppc.setLocalOverride(true);

ppc.setIgnoreUnresolvablePlaceholders(true);

ppc.setIgnoreResourceNotFound(true);

ppc.setProperties(factory.getObject());

return ppc;

}

}

disconf-client 2.6.37 版本修改如下

ConfigLoaderUtils 修改类中的方法,在没有disconf.properties 的情况下,可以在环境变量中获取配置信息,这样便于做通用的镜像,便于管理。

/**

* @param propertyFilePath

* @return Properties

* @throws Exception

* @Description: 配置文件载入器助手

* @author liaoqiqi

* @date 2013-6-19

*/

public static Properties loadConfig(final String propertyFilePath)

throws Exception {

try {

// 用TOMCAT模式 来载入试试

return ConfigLoaderUtils.loadWithTomcatMode(propertyFilePath);

} catch (Exception e1) {

try {

// 用普通模式进行载入

return loadWithNormalMode(propertyFilePath);

} catch (Exception e2) {

// throw new Exception("cannot load config file: "

// + propertyFilePath);

Map map = System.getenv();

Properties properties = new Properties();

for (Iterator itr = map.keySet().iterator(); itr.hasNext(); ) {

String key = itr.next();

System.out.println("环境变量" + key + "=" + map.get(key));

properties.setProperty(key, map.get(key));

}

return properties;

}

}

}

php disconf,未主/disconf相关推荐

  1. disconf mysql_Docker搭建disconf环境,三部曲之三:细说搭建过程

    Docker下的disconf实战全文链接 细说搭建过程 在前两章中,我们利用远程或本地的镜像,快速体验了本地启动disconf的过程,本章我们一起来分析和梳理整个定制和搭建过程,了解这些后,我们就能 ...

  2. disconf mysql_docker 部署disconf 以及将其做成镜像

    1.需要一台服务器(阿里云,腾讯云.实体服务器都行,本次是以实体服务器为依照做的) 3.开始配置disconf 第一步:环境准备 要使用disconf,肯定是开发环境需求,因此需要 mysql 和 r ...

  3. 分布式配置管理平台Disconf

    disconf是一套完整的基于zookeeper的分布式配置统一解决方案 功能特点: 支持配置的分布式化管理,配置发布统一化 极简的使用方式(注解式编程 或 XML代码无代码侵入模式) 需要Sprin ...

  4. Disconf学习1_disconf 入门

    Disconf(一)介绍与对比 一.官方:Distributed Configuration Management Platform(分布式配置管理平台) ;专注于各种 分布式系统配置管理 的通用组件 ...

  5. disconf mysql_disconf浅入浅出(一)disconf简介以及disconf-web端使用

    一.disconf介绍 1.disconf是什么 disconf是一个提供分布式配置管理的软件,所谓分布式配置管理就是为一组或多组分布式环境提供统一的配置管理服务,只需要在web管理控制端修改某个配置 ...

  6. SprinBoot集成disConf的过程梳理

    SprinBoot集成disConf的过程梳理: 打开pom.xml文件,添加disconf-client的依赖关系,工程会自动下载Disconf客户端的jar包 <dependency> ...

  7. 分布式配置中心 Disconf 安装配置

    分布式配置中心 Disconf 安装配置 前提准备 CentOS 服务器一台 MySQL 数据库一台 安装依赖软件 安装 JDK 安装 Git 安装 Maven 安装 Zookeeeper 安装 To ...

  8. disconf连接mysql_Disconf的安装初体验

    单位最近在用Disconf,所以,很有必要玩一下disconf. 其它可参考的文档: http://www.liaoqiqi.com/post/219 1)项目介绍 http://www.oschin ...

  9. disconf java_java disconf使用详解

    业务功能说明 支持用户登录/登出 浏览配置 按 APP/版本/环境 选择 修改配置 修改配置 修改配置项 修改配置文件 新建配置 新建配置项 新建配置文件 新建APP Client使用 在spring ...

最新文章

  1. 教授在飞机上做微积分,被当作恐怖分子抓了......
  2. Keras之小众需求:自定义优化器
  3. [Qt教程] 第48篇 进阶(八) 3D绘图简介
  4. 《Orange’s 一个操作系统的实现》1.搭建操作系统开发环境
  5. 川大的计算机科学分数线,四川大学各排名及分数线整理_四川大学特色分享
  6. 自己动手写Docker系列 -- 3.3使用命令管道优化参数传递
  7. 太任性!17 岁少年买不到回国机票,因“泄愤”找黑客攻击系统,被判刑 4 年...
  8. 企业实战|基于Cobbler实现多版本系统批量部署
  9. 鼠标跟随事件jQuery
  10. 案例学习——网站高并发处理相关技术
  11. 什么是腾讯云图数据可视化?它有哪些特性以及应用场景?
  12. Python实现B样条代码
  13. 数据挖掘技术-绘制人口数目直方图
  14. android文件删除工具下载,Coolmuster Android Cleaner下载
  15. play框架使用起来(17)
  16. java 判断是否回文
  17. 天梭手表Tissot手表更换电池的方法
  18. CDH平台YARN日志查看和问题排查
  19. 揭开真实的加密币地下瑞士银行, 特种部队巡逻、罗斯柴尔德家族投资投资的背后堪比现实版007...
  20. CCF计算机软件能力认证试题练习:201612-2 工资计算

热门文章

  1. 大数据集群服务器的规划,如何安排服务器
  2. python docx转换成txt文本
  3. 浏览器 重定向次数限制_浏览器重定向(302)限制问题
  4. 微信小程序调用python分析图片_小帅丶干货之图像识别在微信小程序展示
  5. 电子商城后台系统(一):使用eclipse构建web项目
  6. 要开发一款游戏---找独立开发者还是游戏外包公司
  7. 驱动开发之 LED(for mini2440)
  8. LitJson输出格式化Json字符串
  9. AutoSAR实验视频讲解:相关资料下载
  10. 时间、延迟及延缓操作