Grails: Pass options to the forked JVM

南楼画角 提交于 2019-12-12 11:44:14

问题


I'm using Grails 2.3.5 and I need to pass an option to the forked JVM. I've tried doing this by setting the JAVA_OPTS environment variable, but that simply gets ignored by the forked JVM. How can I go about passing the forked JVM an option?

I've found this: http://jira.grails.org/browse/MAVEN-177?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel but that's if you're using the Maven plugin I believe. I'm looking for the equivalent but without having to get Maven plugin involved.


回答1:


According to: http://grails.org/doc/2.3.x/guide/commandLine.html#forkedMode (near the bottom of the section) you can use jvmArgs in your grails.project.fork configuration. In BuildConfig:

grails.project.fork = [
    // ...
    run: [maxMemory:1024, minMemory:64, debug:false, maxPerm:256, jvmArgs: '..arbitrary JVM arguments..']
    // ...
]



回答2:


Couldn't post a comment. To clarify Andrew's answer, jvmArgs has to be a list.

grails.project.fork = [
    // ...
    run: [maxMemory:1024, minMemory:64, debug:false, maxPerm:256, jvmArgs: ['-Dsome.prop=true', ...] ]
    // ...
]



回答3:


Using Grails 2.5.1 in forked mode running with the Tomcat 7.0.55.3 plugin, I could not get any of the grails.project.fork.jvmArgs solutions to work. I eventually was able to pass JVM options to the forked process by adding this at the end of my BuildGroovy.config:

grails.tomcat.jvmArgs = ['-jvm_option_here']

See: TomcatServerFactory.groovy



来源:https://stackoverflow.com/questions/21466998/grails-pass-options-to-the-forked-jvm

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