如何控制maven-jetty-plugin的VM参数?

时间:2021-09-19 23:56:51

How to set VM arguments for Jetty run from maven-jetty-plugin?

如何设置Jetty的VM参数从maven-jetty-plugin运行?

For example, I need to pass -Xmx arguments to Jetty run by the mvn jetty:run command.

例如,我需要通过mvn jetty:run命令将-Xmx参数传递给Jetty。

10 个解决方案

#1


52  

The enviroment variable MAVEN_OPTS is the answer. The string content of MAVEN_OPTS is passed to JVM (java.exe).

环境变量MAVEN_OPTS就是答案。 MAVEN_OPTS的字符串内容传递给JVM(java.exe)。

  • Linux: in shell type export MAVEN_OPTS=....
  • Linux:在shell类型导出MAVEN_OPTS = ....
  • Windows: in shell (cmd.exe) type set MAVEN_OPTS=...
  • Windows:在shell(cmd.exe)类型中设置MAVEN_OPTS = ...

For example: on Windows set MAVEN_OPTS="-Xmx1024m" sets the heap size of the Maven process to 1024mb.

例如:在Windows上设置MAVEN_OPTS =“ - Xmx1024m”将Maven进程的堆大小设置为1024mb。

Update (01.04.2013): Pass it directly to Jetty.

更新(01.04.2013):直接传递给Jetty。

Matthew Farwell (please upvote his answer to give him credit) comes with the solution of using a forked JVM process to run Jetty which is a new feature of the Jetty plugin. This is a better solution as the former runs inside same JVM process as Maven (thus shares memory).

Matthew Farwell(请给出他的答案),它提供了使用分叉JVM进程来运行Jetty的解决方案,这是Jetty插件的一个新功能。这是一个更好的解决方案,因为前者在与Maven相同的JVM进程内运行(因此共享内存)。

#2


42  

With more recent versions of the maven-jetty-plugin, you can use mvn:run-forked. The option jvmArgs will allow you to set -Xmx etc.

使用更新版本的maven-jetty-plugin,您可以使用mvn:run-forked。选项jvmArgs将允许您设置-Xmx等。

For more information, see: jetty:run-forked : Running an unassembled webapp in a separate jvm.

有关更多信息,请参阅:jetty:run-forked:在单独的jvm中运行未组装的webapp。

I think the original issue was Starting Jetty in separate JVM.

我认为最初的问题是在单独的JVM中启动Jetty。

#3


12  

It seems like your current approach is correct - when running jetty through maven, jetty is a thread inside the maven process. So increasing maven's heap will increase jetty's heap.

看起来你当前的方法是正确的 - 当通过maven运行jetty时,jetty是maven进程中的一个线程。因此,增加maven的堆将增加jetty的堆。

How are you setting MAVEN_OPTS?

你是如何设置MAVEN_OPTS的?

One example I found looks like this: MAVEN_OPTS='-Xmx256m -Xms10m' mvn clean jetty:run

我发现的一个例子如下:MAVEN_OPTS =' - Xmx256m -Xms10m'mvn clean jetty:run

Note that MAVEN_OPTS is an environment variable here, and not passed to the JVM (who wouldn't know what to do with it).

请注意,MAVEN_OPTS是一个环境变量,不会传递给JVM(谁不知道如何处理它)。

#4


3  

The <jvmArgs> param mentioned here : Maven jetty plugin didn't work for me .

这里提到的 param:Maven jetty插件对我不起作用。

Maven version : Apache Maven 3.0.3

Maven版本:Apache Maven 3.0.3

Jetty Maven plugin version : jetty-maven-plugin:8.1.10.v20130312

Jetty Maven插件版本:jetty-maven-plugin:8.1.10.v20130312

This worked :

这工作:

MAVEN_OPTS='-Xmx4096m -Xms4096m'
export MAVEN_OPTS
mvn jetty:run &

#5


3  

To specify vm arguments via the command line (as originally asked) you can do the following:

要通过命令行指定vm参数(如最初要求的那样),您可以执行以下操作:

mvn clean install -DargLine="-Xmx1524m"

#6


2  

On Linux/Unix

在Linux / Unix上

export MAVEN_OPTS="-Xmx256m" && mvn clean install jetty:run

will do the trick

会做的伎俩

#7


2  

The plugin allows you to specify jvmArgs like this:

该插件允许您指定jvmArgs,如下所示:

<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
    <jvmArgs>-Xmx1024</jvmArgs>
    <scanIntervalSeconds>10</scanIntervalSeconds>
    <connectors>
        <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
            <port>8080</port>
            <maxIdleTime>60000</maxIdleTime>
        </connector>
    </connectors>
    <webAppConfig>
        <jettyEnvXml>jetty-env.xml</jettyEnvXml>
    </webAppConfig>
</configuration>
<executions>
    <execution>
        <phase>test</phase>
        <goals>
            <goal>run-exploded</goal>
        </goals>
    </execution>
</executions>
</plugin>

#8


1  

How about: mvn -DMAVEN_OPTS=-Xmx1024m jetty:run

怎么样:mvn -DMAVEN_OPTS = -Xmx1024m jetty:run

#9


0  

you can use to pass -Xmx argument like;

你可以使用传递-Xmx参数之类的;

<plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version></version>
            <configuration>
                <jvmArgs>-Xmx -Xms -XX:PermSize= -XX:MaxPermSize= -XX:+HeapDumpOnOutOfMemoryError</jvmArgs>
                <scanIntervalSeconds>1</scanIntervalSeconds>
                <stopKey>stop-jetty</stopKey>
                <stopPort>9999</stopPort>
                <systemProperties>
                    <systemProperty>
                        <name>jetty.port</name>
                        <value>9090</value>
                    </systemProperty>
                    <systemProperty>
                        <name>spring.profiles.active</name>
                        <value></value>
                    </systemProperty>
                </systemProperties>

                <webApp>
                    <contextPath>/</contextPath>
                </webApp>
            </configuration>
        </plugin>

#10


0  

There is no way using the commandline. But you could copy the mvn.cmd / mvn.sh to mvnhp.cmd and change the line

无法使用命令行。但您可以将mvn.cmd / mvn.sh复制到mvnhp.cmd并更改该行

%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %CLASSWORLDS_JAR% "-Dclassworlds.conf=%M2_HOME%\bin\m2.conf" "-Dmaven.home=%M2_HOME%" "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS%

To

%MAVEN_JAVA_EXE% -Xmx1024m %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %CLASSWORLDS_JAR% "-Dclassworlds.conf=%M2_HOME%\bin\m2.conf" "-Dmaven.home=%M2_HOME%" "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS%

#1


52  

The enviroment variable MAVEN_OPTS is the answer. The string content of MAVEN_OPTS is passed to JVM (java.exe).

环境变量MAVEN_OPTS就是答案。 MAVEN_OPTS的字符串内容传递给JVM(java.exe)。

  • Linux: in shell type export MAVEN_OPTS=....
  • Linux:在shell类型导出MAVEN_OPTS = ....
  • Windows: in shell (cmd.exe) type set MAVEN_OPTS=...
  • Windows:在shell(cmd.exe)类型中设置MAVEN_OPTS = ...

For example: on Windows set MAVEN_OPTS="-Xmx1024m" sets the heap size of the Maven process to 1024mb.

例如:在Windows上设置MAVEN_OPTS =“ - Xmx1024m”将Maven进程的堆大小设置为1024mb。

Update (01.04.2013): Pass it directly to Jetty.

更新(01.04.2013):直接传递给Jetty。

Matthew Farwell (please upvote his answer to give him credit) comes with the solution of using a forked JVM process to run Jetty which is a new feature of the Jetty plugin. This is a better solution as the former runs inside same JVM process as Maven (thus shares memory).

Matthew Farwell(请给出他的答案),它提供了使用分叉JVM进程来运行Jetty的解决方案,这是Jetty插件的一个新功能。这是一个更好的解决方案,因为前者在与Maven相同的JVM进程内运行(因此共享内存)。

#2


42  

With more recent versions of the maven-jetty-plugin, you can use mvn:run-forked. The option jvmArgs will allow you to set -Xmx etc.

使用更新版本的maven-jetty-plugin,您可以使用mvn:run-forked。选项jvmArgs将允许您设置-Xmx等。

For more information, see: jetty:run-forked : Running an unassembled webapp in a separate jvm.

有关更多信息,请参阅:jetty:run-forked:在单独的jvm中运行未组装的webapp。

I think the original issue was Starting Jetty in separate JVM.

我认为最初的问题是在单独的JVM中启动Jetty。

#3


12  

It seems like your current approach is correct - when running jetty through maven, jetty is a thread inside the maven process. So increasing maven's heap will increase jetty's heap.

看起来你当前的方法是正确的 - 当通过maven运行jetty时,jetty是maven进程中的一个线程。因此,增加maven的堆将增加jetty的堆。

How are you setting MAVEN_OPTS?

你是如何设置MAVEN_OPTS的?

One example I found looks like this: MAVEN_OPTS='-Xmx256m -Xms10m' mvn clean jetty:run

我发现的一个例子如下:MAVEN_OPTS =' - Xmx256m -Xms10m'mvn clean jetty:run

Note that MAVEN_OPTS is an environment variable here, and not passed to the JVM (who wouldn't know what to do with it).

请注意,MAVEN_OPTS是一个环境变量,不会传递给JVM(谁不知道如何处理它)。

#4


3  

The <jvmArgs> param mentioned here : Maven jetty plugin didn't work for me .

这里提到的 param:Maven jetty插件对我不起作用。

Maven version : Apache Maven 3.0.3

Maven版本:Apache Maven 3.0.3

Jetty Maven plugin version : jetty-maven-plugin:8.1.10.v20130312

Jetty Maven插件版本:jetty-maven-plugin:8.1.10.v20130312

This worked :

这工作:

MAVEN_OPTS='-Xmx4096m -Xms4096m'
export MAVEN_OPTS
mvn jetty:run &

#5


3  

To specify vm arguments via the command line (as originally asked) you can do the following:

要通过命令行指定vm参数(如最初要求的那样),您可以执行以下操作:

mvn clean install -DargLine="-Xmx1524m"

#6


2  

On Linux/Unix

在Linux / Unix上

export MAVEN_OPTS="-Xmx256m" && mvn clean install jetty:run

will do the trick

会做的伎俩

#7


2  

The plugin allows you to specify jvmArgs like this:

该插件允许您指定jvmArgs,如下所示:

<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
    <jvmArgs>-Xmx1024</jvmArgs>
    <scanIntervalSeconds>10</scanIntervalSeconds>
    <connectors>
        <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
            <port>8080</port>
            <maxIdleTime>60000</maxIdleTime>
        </connector>
    </connectors>
    <webAppConfig>
        <jettyEnvXml>jetty-env.xml</jettyEnvXml>
    </webAppConfig>
</configuration>
<executions>
    <execution>
        <phase>test</phase>
        <goals>
            <goal>run-exploded</goal>
        </goals>
    </execution>
</executions>
</plugin>

#8


1  

How about: mvn -DMAVEN_OPTS=-Xmx1024m jetty:run

怎么样:mvn -DMAVEN_OPTS = -Xmx1024m jetty:run

#9


0  

you can use to pass -Xmx argument like;

你可以使用传递-Xmx参数之类的;

<plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version></version>
            <configuration>
                <jvmArgs>-Xmx -Xms -XX:PermSize= -XX:MaxPermSize= -XX:+HeapDumpOnOutOfMemoryError</jvmArgs>
                <scanIntervalSeconds>1</scanIntervalSeconds>
                <stopKey>stop-jetty</stopKey>
                <stopPort>9999</stopPort>
                <systemProperties>
                    <systemProperty>
                        <name>jetty.port</name>
                        <value>9090</value>
                    </systemProperty>
                    <systemProperty>
                        <name>spring.profiles.active</name>
                        <value></value>
                    </systemProperty>
                </systemProperties>

                <webApp>
                    <contextPath>/</contextPath>
                </webApp>
            </configuration>
        </plugin>

#10


0  

There is no way using the commandline. But you could copy the mvn.cmd / mvn.sh to mvnhp.cmd and change the line

无法使用命令行。但您可以将mvn.cmd / mvn.sh复制到mvnhp.cmd并更改该行

%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %CLASSWORLDS_JAR% "-Dclassworlds.conf=%M2_HOME%\bin\m2.conf" "-Dmaven.home=%M2_HOME%" "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS%

To

%MAVEN_JAVA_EXE% -Xmx1024m %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %CLASSWORLDS_JAR% "-Dclassworlds.conf=%M2_HOME%\bin\m2.conf" "-Dmaven.home=%M2_HOME%" "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS%