问题
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