Friday 15 July 2011

Grails Jar'd Configuration Property Files

Say you have an existing Java project which has a plethora of configuration property files and you want to use some of these properties in your new Grails project. How can you do this? One approach is to:
  1. Put all your property files into a jar and place the jar in the 'lib' directory of your grails project
  2. Modify the Config.groovy and add the line -
    grails.config.locations = [ "classpath:file1.properties", "classpath:file2.properties" ]
  3. Then depending where you are in the app you have access to the property variables and can dereference them e.g. ${my.file1.prop}

No comments:

Post a Comment