Created
October 26, 2016 07:22
-
-
Save quchie/64424f65c13741a67e181f51936a1b51 to your computer and use it in GitHub Desktop.
Merge properties files with grails config in runtime
This file contains 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
//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