Search code examples
scalatypesafe-config

Typesafe ConfigFactory load error


I'm trying to load the application.conf that I have under my resources folder using the following line:

val config = ConfigFactory.load(getClass.getResource("application.conf").getPath)

However, it fails and the application.conf is not loaded. There is no error or whatsoever. Any ideas as to what to look for?


Solution

  • ConfigFactory.load takes a resource-name as parameter not a complete path. So it should be enough if you just use "application.conf" as argument, like this:

    ConfigFactory.load("application.conf")
    

    As "application.conf is the default name anyways it should actually be enough to just go without arguments:

    ConfigFactory.load()