I have application.conf file on my classpath, included in the jar:
{
db.class : "org.h2.Driver"
db.url : "jdbc:h2:~/database.db"
db.username : sa
db.password : ""
}
And I want my app to use external .conf file, which is /home/user/cfg/app.conf:
{
db.class : "org.h2.Driver"
db.url : "jdbc:h2:~/prod.db"
db.username : someusername
db.password : somepassword
}
I launch my app with -Dconfig.file option:
java -Dconfig.file="/home/user/cfg/app.conf" -jar application.jar
But ConfigFactory.load() still loads application.conf from classpath, ignoring the external file.
What am I doing wrong?
Did you happen to read through the Standard behavior of typesafe config at Standard behavior ?
Perhaps you could try their suggestion.
It says "These system properties specify a replacement for application.{conf,json,properties}, not an addition. They only affect apps using the default ConfigFactory.load() configuration. In the replacement config file, you can use include "application" to include the original default config file; after the include statement you could go on to override certain settings."