You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm encountering an issue while attempting to load two configs in Scala using the Typesafe Config library, where the second config needs to reference variables in the first one. I probably doing something wrong but I can't find any online solution.
Here is my code:
class ScalaCentralSharedLibConfigManager() {
val configString =
"""
|logger {
| elasticsearch {
| servers {
| prod {
| host = "http://example.com"
| }
| }
| }
|}
""".stripMargin
var internalConsulConfig: Config = ConfigFactory.parseString(configString).resolve()
var internalConfig: Config = ConfigFactory.load("sharedlibapplication.conf").withFallback(internalConsulConfig).resolve()
Within my sharedlibapplication.conf I have the following:
When I run the code, I get the error: "Could not resolve substitution to a value: ${logger.elasticsearch.servers.prod.host}"
Any guidance or assistance with this issue would be much appreciated.
the docs for load(String) explain the likely issue - load does the resolve already before you add the fallback. You could use parse instead, or could use load(Config).
I'm encountering an issue while attempting to load two configs in Scala using the Typesafe Config library, where the second config needs to reference variables in the first one. I probably doing something wrong but I can't find any online solution.
Here is my code:
Within my sharedlibapplication.conf I have the following:
When I run the code, I get the error: "Could not resolve substitution to a value: ${logger.elasticsearch.servers.prod.host}"
Any guidance or assistance with this issue would be much appreciated.
The desired output is:
The text was updated successfully, but these errors were encountered: