We started off with separate YAML files per environment (production and US, production and UK, production and JP, dev and US, etc.), but that got old really quick. So I built a little code around Typesafe Config (
https://github.com/typesafehub/config). It is kind of a hack, but since it only happens at start up time, I'm OK with it.
Basically I write all my configuration using HOCON (
https://github.com/typesafehub/config/blob/master/HOCON.md). I then pull it through the following code...
final Config defaults = getDefaults(allConfig, domain, realm);
final Config domainAndRealmConfig = getDomainAndRealmConfig(allConfig, domain, realm);
final Config domainConfig = getDomainConfig(allConfig, domain, realm);
final Config realmConfig = getRealmConfig(allConfig, realm);
return combine(defaults, domainAndRealmConfig, domainConfig, realmConfig);