[英]Spring import all configuration files in a directory into another configuration file without specifying the profiles / filenames explicitly
有沒有一種方法可以導入目錄中的所有配置文件,而不必一一明確指定它們的配置文件/文件名?
我想過使用spring.config.import
但它似乎不支持指定目錄或模式來動態導入目錄中包含的任何配置文件。
例如:
我在config/
目錄中有主配置application.yml
和子配置,其中包含application-test1.yml
、 application-testN.yml
等。 我想自動加載目錄下的所有配置文件,而不在application.yml
中明確指定它們。
我在下面嘗試了這些,但它們不起作用。
spring
config
import: classpath:config/
spring
config
file: file:config/*/
spring.config.location=classpath:/custom-config/
這應該從指定的文件夾加載配置。 根據不同的配置文件配置,只會導入活動配置文件配置,因此您需要確保加載的標准配置文件激活這些配置文件(例如,使用spring.profiles.include
)
更多參考資料:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.