开发者

How do i set up a grails environment variable?

I have a folder in my d drive.files in this drive i am using in my controller.so in controller i am specifying tht folder name for t开发者_运维技巧o each file recurse.But after development files may be saved in any other drive.so I want have environment variable for it.how to do that


It sounds like a configuration parameter would be better than an environment variable. Config.groovy is environment aware, 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 is deprecated, so you should read config parameters using this instead:

def fileLocation = grailsApplication.config.fileLocation
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜