Specifying system properties in Grails 2.0 interactive mode
-
30-01-2021 - |
Question
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 -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
La solution
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
.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow