Knows Not Much
Knows Not Much

Reputation: 31546

duplicate application.conf in typesafe config projects

I am reading some code which uses typesafe config to read the application.conf file in the resource folder. I am using a library which has a application.conf in its resource folder and I call this library from another project which has its own application.conf in its resources folder.

Will typesafe config be able to read the right config files respectively?

Upvotes: 2

Views: 722

Answers (1)

Alexey Romanov
Alexey Romanov

Reputation: 170733

From documentation:

The substitution syntax ${foo.bar} will be resolved twice. First, all the reference.conf files are merged and then the result gets resolved. Second, all the application.conf are layered over the reference.conf and the result of that gets resolved again.

So, both libraries will see the same Config, which is the result of merging both application.conf (assuming both use default behavior and there are no more application.conf or reference.conf files on the classpath). Each library should not just put its configuration in the root, but instead have its own part of config tree: i.e. not

debug = true
server = "example.com"

but

my.cool.library {
  debug = true
  server = "example.com"
}

If this rule is followed, the libraries won't conflict. If they use the same path with different meaning, you will have trouble.

Upvotes: 3

Related Questions