Hi,
I'm using the same config library
(
https://github.com/typesafehub/config) that Akka uses to load
configuration settings, but can't get it to work.
Here's my code:
import com.typesafe.config._
val conf = ConfigFactory.load()
println("Server port: " + conf.getString("devserver.port"))
Here is the application.conf file:
devserver {
port = 80
}
I'm using IntelliJ Idea as dev tool, but also tried sbt from the command line. In both cases I get:
Exception in thread "main" java.lang.ExceptionInInitializerError
at MSG.main(MSG.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'devserver.port'
at com.typesafe.config.impl.SimpleConfig.findKey(SimpleConfig.java:126)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:148)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:119)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:157)
at com.typesafe.config.impl.SimpleConfig.getString(SimpleConfig.java:199)
at MSG$.<init>(MSG.scala:48)
at MSG$.<clinit>(MSG.scala)
... 6 more
Other
config info prints out fine with println(conf.root.render), but my
devserver stuff is not among it. Maybe it's a classpath issue, but I
tried placing the application.conf in the project root folder and all
other source folders and it still would not pick it up. Any idea where
it will start looking for the file by default in a simple sbt project?
(if this is the problem)
As a test I cloned the typesafe/config
project from github, but it has has many broken dependencies when trying
to do sbt update.
Regards,
Jacobus