开发者

Specifying system properties in Grails 2.0 interactive mode

Is there a way how to specify system property in (already started) grails interactive mode ?

For example I would specify environment in command line:

grails开发者_如何学Go -Dgrails.env=staging run-app

but in interactive mode it is not possible this way (since JVM is already started):

grails
grails> -Dgrails.env=staging run-app


This seems to work in Grails 1.3.7 interactive mode. Add a script to your Grails application at scripts/SetProperty.groovy:

includeTargets << grailsScript('_GrailsArgParsing')

target (default:'Set a system property') {
    depends('parseArguments')
    if (argsMap['params'][0] && argsMap['params'][1]) {
        System.setProperty(argsMap['params'][0], argsMap['params'][1])
    } else {
        println 'You must define a property to set'
    }
}

Then in interactive mode set-property grails.env staging.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜