How to set up Grails environment variable?

I have a folder in my d drive.files on this drive that I use in my controller. In the controller, I specify the tht file name for each file replication. But after the development files can be saved on any other disk. therefore I want to have an environment variable for it. How to do it

+4
source share
1 answer

It looks like the configuration option will be better than the environment variable. Config.groovy supports the environment, so you can specify different values ​​for development, production, etc.

 environments { production { fileLocation = "D:/" } development { fileLocation "/somewhere/else" } test { fileLocation "/production/somewhere" } } 

You can read the value of this parameter with:

 def fileLocation = org.codehaus.groovy.grails.commons.ConfigurationHolder.config?.fileLocation 

in grails 1.4 ConfigurationHolder deprecated, so you should read the configuration options instead:

 def fileLocation = grailsApplication.config.fileLocation 
+6
source

All Articles