I need to include some properties file into my typesafe config, like
include ${user.HOME}"/.app/db-test.conf"
however parser complains:
com.typesafe.config.ConfigException$Parse: dev/application.conf: 47: include keyword is not followed by a quoted string, but by: '${'user.HOME'}'
com.typesafe.config.ConfigException$Parse: dev/application.conf: 47: include keyword is not followed by a quoted string, but by: '${'user.HOME'}'
at com.typesafe.config.impl.Parser$ParseContext.parseError(Parser.java:329)
at com.typesafe.config.impl.Parser$ParseContext.parseError(Parser.java:325)
at com.typesafe.config.impl.Parser$ParseContext.parseInclude(Parser.java:574)
at com.typesafe.config.impl.Parser$ParseContext.parseObject(Parser.java:624)
at com.typesafe.config.impl.Parser$ParseContext.parseValue(Parser.java:408)
at com.typesafe.config.impl.Parser$ParseContext.parseObject(Parser.java:657)
at com.typesafe.config.impl.Parser$ParseContext.parse(Parser.java:832)
at com.typesafe.config.impl.Parser.parse(Parser.java:34)
How can I use system properties/environment variables in include statements?
Can you do this manually in the code that loads your config?
Config baseConfig = ConfigFactory.load();
// Probably want error checking here.
Config testConfig = ConfigFactory.parseFile(
new File(System.getenv("HOME") + "/.app/db-test.conf"));
// You may need to change your resolution order, depending on what you're doing in your
// default config.
testConfig.resolve();
Config finalConfig = baseConfig.withFallback(testConfig);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With