disconf源码解读(1)

怼烎@ 2022-07-12 12:45 298阅读 0赞

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

  1. # 是否使用远程配置文件 # true(默认)会从远程获取配置 false则直接获取本地配置
  2. disconf.enable.remote.conf=true
  3. # 配置服务器的 HOST,用逗号分隔(动态配置服务器地址) 127.0.0.1:8000,127.0.0.1:8000
  4. disconf.conf_server_host=10.202.4.179:8015
  5. # 版本, 请采用 X_X_X_X 格式
  6. disconf.version=1_0_0_0
  7. # APP(由运维统一分配,按具体分配值配置)
  8. disconf.app=sgs_smp
  9. # 环境(local、rd、qa、online)依次(本地、开发、测试、生产)
  10. disconf.env=dev
  11. # 忽略哪些分布式配置,用逗号分隔
  12. disconf.ignore=
  13. # 获取远程配置 重试次数,默认是3次
  14. disconf.conf_server_url_retry_times=1
  15. #获取远程配置 重试时休眠时间,默认是5秒
  16. disconf.conf_server_url_retry_sleep_seconds=1
  17. # 用户指定的下载文件夹, 远程文件下载后会放在这里
  18. 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";
然后导入这个指定的文件,读取其中的配置。

发表评论

表情:
评论列表 (有 0 条评论,298人围观)

还没有评论,来说两句吧...

相关阅读