No configuration setting found for key typesafe config
The error message is telling you that whatever configuration got read, it didn't include a top level setting named add
. The ConfigFactory.load
function will attempt to load the configuration from a variety of places. By default it will look for a file named application
with a suffix of .conf
or .json
. It looks for that file as a Java resource on your class path. However, various system properties will override this default behavior.
So, it is likely that what you missed is one of these:
- Is it possible that
src/main/resources
is not on your class path? - Are the
config.file
,config.resource
orconfig.url
properties set? - Is your
application.conf
file empty? - Do you have an
application.conf
that would be found earlier in your class path? - Is the key:
add
defined in theapplication.conf
?
Are you using an IDE or sbt? I had a similar problem while using Eclipse. It simply did not find the application.conf file at first and later on failed to notice edits. However, once I ran my program via sbt, all worked just fine, including Eclipse. So, I added 'main/resources' to the libraries (Project -> Properties -> Java Build Path -> Libraries", "add class folder"). That might help you as well.