Scala: How to include other conf files from other directories in base config file?

49 Views Asked by At

I have a Scala app with a base config file, local.conf. It is getting a bit large, so I want to split it up and I want to have those parts located in a child directory src/main/resources/local. Adding the include to the local.conf doesn't work. It errors about not finding the resulting config keys. Why doesn't include allow me to add files from other directories? How to fix?

Folder Structure

src->main->resources:
application.conf
local.conf
prod.conf
local/more_config.conf
prod/more_config.conf

local.conf

include "secrets.conf"
include "local/more_config.conf"

myApp ${localConfig} {
    buildEnv: "local"
}

local/more_config.conf

localConfig {
    mysqlConfig {
        user: "blah",
        password: "blah",
        host: "localhost:3306"
    }
}

Error: Could not resolve substitution to a value: ${localConfig}

However, if I move the more_config.conf file to the same resources directory and change my include, it works fine... ¯_(ツ)_/¯

Using https://github.com/lightbend/config

Why is this? How to fix?

0

There are 0 best solutions below