[英]Typesafe Config overriding values from external file
I have all my configuration set into application.conf which locates under src/main/resources. 我将所有配置都设置到位于src / main / resources下的application.conf中。 and it works fine when I run my app in production mode.
当我在生产模式下运行我的应用程序时,效果很好。
val config = ConfigFactory.load()
In some certain situation when I run my app in docker container and I need to override about 30 of properties. 在某些情况下,当我在docker容器中运行我的应用程序时,我需要覆盖大约30个属性。
When I add 当我添加
-Dconfig.file="/etc/deployed.conf"
it excludes all original properties which contains "application.conf" and are not overriden in "deployed.conf". 它排除了所有包含“ application.conf”且未在“ deployed.conf”中覆盖的原始属性。
Is there any way to solve this issue? 有什么办法解决这个问题?
Update: Will 更新:将
val myCfg = ConfigFactory.parseFile(new File("etc/deployed.conf"))
val config = ConfigFactory.load().withFallback(myCfg)
override values in application.conf and will not throw any exception if this file does not exist? 覆盖application.conf中的值,如果此文件不存在,将不会引发任何异常?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.