Skip to content

Instantly share code, notes, and snippets.

@quchie
Created October 26, 2016 07:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quchie/64424f65c13741a67e181f51936a1b51 to your computer and use it in GitHub Desktop.
Save quchie/64424f65c13741a67e181f51936a1b51 to your computer and use it in GitHub Desktop.
Merge properties files with grails config in runtime
//Merges Properties file with config grails
Properties properties = new Properties()
//Lets say we have file in web-app/settings/setting.properties folder
File propertiesFile = grailsApplication.mainContext.getResource("settings/settings.properties").file
propertiesFile.withInputStream {
properties.load(it)
}
ConfigSlurper cs = new ConfigSlurper()
ConfigObject co = cs.parse(properties)
//Merges only the settings we need. leaves everything else intact
grailsApplication.config.merge(co)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment