我已经尝试了下面的方法,但都不起作用。我正在尝试从服务器远程访问jmx。
<jvmArgs>
<jvmArg>-Dcom.sun.management.jmxremote.port=9999</jvmArg>
<jvmArg>-Dcom.sun.management.jmxremote.authenticate=false</jvmArg>
<jvmArg>-Dcom.sun.management.jmxremote.ssl=false</jvmArg>
</jvmArgs>
<!-- <systemPropertyVariables>
<com.sun.management.jmxremote.port>9999</com.sun.management.jmxremote.port>
<com.sun.management.jmxremote.authenticate>false</com.sun.management.jmxremote.a uthenticate>
<com.sun.management.jmxremote.ssl>false</com.sun.management.jmxremote.ssl>
</systemPropertyVariables> -->
<!-- <jvmArguments>
<jvmArgument>- Dcom.sun.management.jmxremote.port=9999</jvmArgument>
<jvmArgument>- Dcom.sun.management.jmxremote.authenticate=false</jvmArgument>
<jvmArgument>- Dcom.sun.management.jmxremote.ssl=false</jvmArgument>
</jvmArguments> -->我也试过了
<options>
<option>-Dcom.sun.management.jmxremote.port=9999</option>
<option>-Dcom.sun.management.jmxremote.authenticate=false</option>
<option>-Dcom.sun.management.jmxremote.ssl=false</option>
</options>发布于 2016-09-28 23:01:18
您可以在不同的点和级别为Maven设置Java选项(全局或通过插件配置):
插件配置:仅用于编译
使用用于编译应用程序代码和测试代码的Maven Compiler Plugin配置,您可以通过compileArgs配置条目设置所需的Xmx、Xms、Xss选项,该条目可用于compile和testCompile目标。一个官方的例子可以在here和其他像this one这样的SO答案上找到。下面还显示了一个示例。
插件配置:仅用于测试执行
使用用于测试执行的Maven Surefire Plugin配置,您可以通过test目标的argLine配置条目来设置在运行时使用的所需的Maven Surefire Plugin选项。一个官方的例子是here。关于第三点,下面还显示了一个示例。
插件配置:通过属性(和配置文件)
您可以将上面的两个选项(对于公共Java选项)组合为一个属性值,以同时传递给compileArgs和argLine配置条目,或者根据您的需要为每个配置提供不同的属性。
<property>
<jvm.options>-Xmx256M</jvm.options>
</property>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<compilerArgs>
<arg>${jvm.options}</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<argLine>${jvm.options}</argLine>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]使用属性还为您提供了两个额外的优势(在集中化之上):您可以使用配置文件,然后根据不同的期望行为(以及此SO answer中的示例)对其进行个性化设置,并且您也可以通过命令行覆盖它们,例如:
mvn clean install -Djvm.options=-Xmx512https://stackoverflow.com/questions/39750348
复制相似问题