Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

com.typesafe.config.ConfigException$NotResolved: has not been resolved,

I am trying to read the following config file using typesafe config

common = {
  jdbcDriver = "com.mysql.jdbc.Driver"
  slickDriver = "slick.driver.MySQLDriver"
  port = 3306
  db = "foo"
  user = "bar"
  password = "baz"
}

source = ${common} {server = "remoteserver"}
target = ${common} {server = "localserver"}

When I try to read my config using this code

val conf = ConfigFactory.parseFile(new File("src/main/resources/application.conf"))
val username = conf.getString("source.user")

I get an error

com.typesafe.config.ConfigException$NotResolved: source.user has not been resolved, you need to call Config#resolve(), see API docs for Config#resolve()

I don't get any error if I put everything inside "source" or "target" tags. I get errors only when I try to use "common"

like image 787
Knows Not Much Avatar asked Jan 08 '17 01:01

Knows Not Much


1 Answers

I solved it myself.

ConfigFactory.parseFile(new File("src/main/resources/application.conf")).resolve()
like image 129
Knows Not Much Avatar answered Sep 18 '22 21:09

Knows Not Much