Created
August 19, 2013 16:29
-
-
Save raulraja/6271058 to your computer and use it in GitHub Desktop.
Load application.conf overrides based on runtime environment and merge in overridden props. e.g. application.dev.conf, application.prod.conf, application.test.conf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
# Global object class | |
# ~~~~~ | |
# Define the Global object class for this application. | |
# Default to Global in the root package. | |
application.global = com.company.Global | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.company | |
import play.api.{Mode, Configuration, GlobalSettings} | |
import java.io.File | |
import com.typesafe.config.ConfigFactory | |
object Global extends GlobalSettings { | |
override def onLoadConfig(config: Configuration, path: File, classloader: ClassLoader, mode: Mode.Mode): Configuration = { | |
println(s"loading config path: $path") | |
val configOverridePath = s"application.${mode.toString.toLowerCase}.conf" | |
val modeSpecificConfig = config ++ Configuration(ConfigFactory.load(configOverridePath)) | |
println(s"merged config: $configOverridePath") | |
super.onLoadConfig(modeSpecificConfig, path, classloader, mode) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment