You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Maven+Jenkins运行JMeter脚本时,如何添加指定JVM参数解决模块报错

解决JMeter Maven插件运行时的JVM模块访问错误

你遇到的错误是Java 9+模块系统的限制导致的——Parallel Controller插件需要访问java.lang包的内部API,但默认情况下JVM不允许未命名模块访问这些受限包。要修复这个问题,只需在pom.xml的jmeter-maven-plugin配置中添加指定的JVM参数即可。

具体配置步骤

找到pom.xml中com.lazerycode.jmeter:jmeter-maven-plugin的配置块,添加jvmArguments节点,将--add-opens java.base/java.lang=ALL-UNNAMED参数填入其中:

<plugin>
    <groupId>com.lazerycode.jmeter</groupId>
    <artifactId>jmeter-maven-plugin</artifactId>
    <version>3.8.0</version>
    <executions>
        <execution>
            <id>jmeter-tests</id>
            <goals>
                <goal>jmeter</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <!-- 添加JVM参数 -->
        <jvmArguments>--add-opens java.base/java.lang=ALL-UNNAMED</jvmArguments>
        <!-- 确保Parallel Controller插件依赖正确 -->
        <jmeterPlugins>
            <plugin>
                <groupId>com.blazemeter</groupId>
                <artifactId>jmeter-parallel</artifactId>
                <version>0.12</version>
            </plugin>
        </jmeterPlugins>
    </configuration>
</plugin>

注意事项

  • 确认你的Maven构建环境(包括Jenkins中配置的Maven)使用的JDK版本是OpenJDK 17.0.9,避免环境不一致导致的问题。
  • 如果需要添加多个JVM参数,可以用空格分隔,比如--add-opens java.base/java.lang=ALL-UNNAMED -Xmx2g。

内容的提问来源于stack exchange,提问作者Vel Ganesh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 11:47:05