How to add custom “-Djava” arguments to Grails app?

一笑奈何 提交于 2020-01-04 04:40:10

问题


Say I wanted to run a Grails (2.3+) app with an extra "-Djava.fizz.buzz=3" JVM arg.

Is it as simple as:

grails run-app -Djava.fizz.buzz=3

Or is there special config (say, in BuildConfig.groovy) that would need to take place?


回答1:


The answer to your question is yes, that will work. JVM args work a bit differently. Both are in the docs about the command line.




回答2:


That should work. And to have access to the arg you just created, you may call System.properties[] anywhere in your code:

if (System.properties['java.fizz.buzz'] == '3') {
    ...
}



回答3:


grails -Djava.fizz.buzz=3 run-app


来源:https://stackoverflow.com/questions/23396389/how-to-add-custom-djava-arguments-to-grails-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!