一、前言
最近因項目需要,準備入手研究百度開源的分佈式配置中心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已經沒人維護了,官方給出的羣也加不上,估計這個開源項目要被遺棄了。