I am writing test code to validate a RESTful service. I want to be able to point it at any of our different environments by simply changing an environment variable before execu
The answer is to use ConfigFactory.parseResource()
in place of ConfigFactory.load()
.
Here is the finished result
private lazy val defaultConfig = ConfigFactory.parseResources("conf/env/default.conf")
private lazy val environmentConfig = ConfigFactory.parseResources("conf/env/" + env + ".conf" )
private lazy val userConfig = ConfigFactory.parseResources("application.conf")
private lazy val config = ConfigFactory.load()
.withFallback(userConfig)
.withFallback(environmentConfig)
.withFallback(defaultConfig)
.resolve()