Skip to content

Instantly share code, notes, and snippets.

@dmahapatro
Created February 4, 2015 17:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dmahapatro/97fc8fd571cf41a22b85 to your computer and use it in GitHub Desktop.
Save dmahapatro/97fc8fd571cf41a22b85 to your computer and use it in GitHub Desktop.
YAML to Groovy Config
// Run in Grails context inside grails console
// Below will be helpful to create "application.groovy" from "application.yml" in Grails 3
// which will be an easy porting experiance from Grails 2.* to Grails 3
// In future, this can be added to a grails command and/or added to a Grails profile.
import org.springframework.beans.factory.config.YamlMapFactoryBean
import org.springframework.core.io.ClassPathResource
import org.springframework.core.io.Resource
YamlMapFactoryBean factory = new YamlMapFactoryBean()
factory.setResources( [ new ClassPathResource( 'application.yml' ) ] as Resource[] )
new ConfigObject( factory.object ) //.toProperties() if required
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment