disconf源码解读(1)

版权声明:原创文章,转载请注明出处。 https://blog.csdn.net/aitcax/article/details/56680298

使用disconf的时候,需要在classpath中添加一个配置文件:disconf.properties

# 是否使用远程配置文件 # true(默认)会从远程获取配置 false则直接获取本地配置 
disconf.enable.remote.conf=true
# 配置服务器的 HOST,用逗号分隔(动态配置服务器地址) 127.0.0.1:8000,127.0.0.1:8000 
disconf.conf_server_host=10.202.4.179:8015
# 版本, 请采用 X_X_X_X 格式 
disconf.version=1_0_0_0
# APP(由运维统一分配,按具体分配值配置) 
disconf.app=sgs_smp
# 环境(local、rd、qa、online)依次(本地、开发、测试、生产) 
disconf.env=dev
# 忽略哪些分布式配置,用逗号分隔 
disconf.ignore=
# 获取远程配置 重试次数,默认是3次 
disconf.conf_server_url_retry_times=1
#获取远程配置 重试时休眠时间,默认是5秒 
disconf.conf_server_url_retry_sleep_seconds=1
# 用户指定的下载文件夹, 远程文件下载后会放在这里 
disconf.user_define_download_dir=./disconf/download2

1.在项目的spring配置中,并没有显示的加载disconf.properties,name这个文件是在哪里指定的呢?
通过查看源码,发现在disconf-client包中的com.baidu.disconf.client.config.DisClientConfig类里定义了
protected static final String filename = "disconf.properties";
然后导入这个指定的文件,读取其中的配置。

猜你喜欢

转载自blog.csdn.net/aitcax/article/details/56680298