Reputation: 15435
I'm having a SBT Multi Module project where in some of the sub modules, I'm actually having a place holder to resolve certain configurations. The project structure looks like this:
core
src
main
resources
application.conf
mod1
src
main
resources
application.conf
mod2
src
main
resources
application.conf
In the module2, in my application.conf, I have the following:
# The environment representation of the configurations
# ~~~~~
app {
environment = "test"
name = ${NAME}-split # TODO: Get the default name from application.conf which should also be located here
}
As it can be seen that the NAME is a place holder that I would like to inherit from either the default application.conf that I include or pass it in via a command line argument. As expected, I get to see compiler error like this:
[error] at java.base/java.lang.Thread.run(Thread.java:829)
[error] Caused by: com.typesafe.config.ConfigException$UnresolvedSubstitution: application.test.conf @ file:/home/runner/work/housing-price-prediction-data-preparation/housing-price-prediction-data-preparation/split/target/scala-2.12/test-classes/application.test.conf: 7: Could not resolve substitution to a value: ${NAME}
[error] at com.typesafe.config.impl.ConfigReference.resolveSubstitutions(ConfigReference.java:108)
Upvotes: 1
Views: 186
Reputation: 1210
Normally you would put a reference.conf per module and an application.conf at the top application level.
Also note the module level configs are resolved first (in order, first th lower modules than the ones that depend on those). Then the application.conf and finally overrides from the command line.
The order is important, you can't depend on things not yet set, or if they are set to an intem value and then overriden. the dependent config will be based on the one effective when it is resolved.
Upvotes: 1