一、前言
最近因项目需要,准备入手研究百度开源的分布式配置中心disconf,在涉及到配置文件下载路径的时候,发现本地测试的情况跟官网说的不太一样(官网 点击打开链接 ),这里做个记录以便及时查看。后面的测试主要是基于springboot的。
二、测试模拟
我使用的disconf版本是目前的最新版2.6.36。在测试之前,先说明几个和路径相关的配置。
targetDirPath:指用户在类上面指定的某个配置文件的下载路径
disconf.enable_local_download_dir_in_class_path:指配置文件下载到根目录下(默认问true)
disconf.user_define_download_dir:指用户自定义的配置文件下载路径
2.1 如果targetDirPath为空,设置了disconf.user_define_download_dir,会下载到所设置的值下面,同时生成一个默认的目录disconf/download(但是这个下面没有文件,我理解的这个是相对于配置文件来说的跟目录)。
2.2 如果targetDirPath为空,不设置disconf.user_define_download_dir,会下载到disconf/download下面(无论disconf.enable_local_download_dir_in_class_path=false或者true)
2.3 如果targetDirPath不为空,且设置了disconf.enable_local_download_dir_in_class_path=true,还是只是在classpath下有一个disconf/download文件夹下面,并没有新生成一个config文件夹。
2.4 如果targetDirPath不为空,且设置了disconf.enable_local_download_dir_in_class_path=false(不设置disconf.user_define_download_dir),在项目根目录下有一个disconf文件夹下面,并没有新生成一个config文件夹(disconf2.6.36版本默认会生成一个disconf/download)
2.5 如果targetDirPath不为空,且设置了disconf.user_define_download_dir=src/main/resources(不设置disconf.enable_local_download_dir_in_class_path),那么会在src/main/resources下有配置文件,同时会生成一个空的disconf/download目录,并没有新生成一个config文件夹。
三、结论
综上测试,发现targetPath设置根本就不起作用,刚刚在github上看到,disconf已经没人维护了,官方给出的群也加不上,估计这个开源项目要被遗弃了。