I have all my configuration set into application.conf which locates under src/main/resources. 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.
When I add
-Dconfig.file="/etc/deployed.conf"
it excludes all original properties which contains "application.conf" and are not overriden in "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?
If you create it manually you can use the withFallback method.
Config appConfig = ConfigFactory.parseResources(configs.remove(0));
for (String resource : configs) {
appConfig = appConfig.withFallback(ConfigFactory.parseResources(resource));
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.