Setting System property from command line in grails

24 / Aug / 2011 by Vishal Sahu 0 comments

Hi,

In one of my recent grails project, i needed to set System property from command line while running the grails application.
I looked for it and found a simple solution to do so and found it worth sharing.

Suppose we want to set any property, say app.property=”propertyValue”, then the command to set the property in grails application would be:

[java]
grails -Dapp.property="propertyValue" run-app

[/java]

Similarly to retrieve the value of System property, we use

[java]
String myPropertyValue= System.getProperty("app.property")
[/java]

It helped me a lot..
Hope it helps

Vishal Sahu
vishal@intelligrape.com

FOUND THIS USEFUL? SHARE IT

Tag -

Linux System

Leave a Reply

Your email address will not be published. Required fields are marked *