Im trying to implement a configuration tool typesafehub/config im using this code
val conf = ConfigFactory.load() val url = conf.getString("add.prefix") + id + "/?" + conf.getString("add.token")
And the location of the property file is /src/main/resources/application.conf
But for some reason i'm receiving
com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'add'
File content
add { token = "access_token=6235uhC9kG05ulDtG8DJDA" prefix = "https://graph.facebook.com/v2.2/" limit = "&limit=250" comments="?pretty=0&limit=250&access_token=69kG05ulDtG8DJDA&filter=stream" feed="/feed?limit=200&access_token=623501EuhC9kG05ulDtG8DJDA&pretty=0" }
Everything looks configured correctly ?? do i missed something .
thanks,
miki
Overview. Recently I discovered an awesome Java library about configuration — Typesafe Config (GitHub). It supports Java properties, JSON and a human-friendly JSON superset. It can load resources from different places: files, URLs, classpath. It supports types, loading convention, substitutions, properties merging, etc ...
An application configuration file is an XML file used to control assembly binding. It can redirect an application from using one version of a side-by-side assembly to another version of the same assembly. This is called per-application configuration.
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:
src/main/resources
is not on your class path? config.file
, config.resource
or config.url
properties set?application.conf
file empty?application.conf
that would be found earlier in your class path?add
defined in the application.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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With