I have the following application.conf file:
# App
tables = [
"table_1",
"talbe_2"
]
and the following scala code:
import pureconfig._
import pureconfig.generic.auto._
import com.typesafe.config.ConfigFactory
import pureconfig.generic.ProductHint
case class Configuration(tables: Array[String])
object Config {
implicit def hint[A] = ProductHint[A](ConfigFieldMapping(CamelCase, CamelCase))
val conf = ConfigSource.fromConfig(ConfigFactory.load("application.conf")).load[Configuration] match {
case Right(conf) => conf
case Left(failures) => throw new Exception(s"Unable to load the configuration ${failures.toList.mkString("\n")}")
}
}
and to test the application.conf, I have this code:
object Test extends App {
val res = Config.conf.tables
println("hello")
}
when I drop application.conf in resources folder, it works. But It does not works when i use
-Dconfig.file=C:/Users/path/to/application.conf
It use the resources application.conf file despite the one in argument -Dconfig.file. Do you have any idea?
The problem is the call
From scaladocs
You have to use
which
And
defaultApplication
supportsconfig.file