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

Maven项目使用jdk.incubator.vector遇编译运行错误求助

解决Maven项目中使用jdk.incubator.vector的编译错误

1. 升级并修正maven-compiler-plugin配置

你当前使用的maven-compiler-plugin 3.8.1版本对JDK17的适配性不足,建议升级到3.11.0版本,同时确保编译参数正确传递:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.11.0</version>
    <configuration>
        <release>17</release>
        <compilerArgs>
            <arg>--add-modules</arg>
            <arg>jdk.incubator.vector</arg>
        </compilerArgs>
    </configuration>
</plugin>

2. 修复maven-surefire-plugin的参数配置

你当前重复定义了<argLine>标签,这会导致只有最后一个参数生效,需将模块参数合并到同一个标签中:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.22.2</version>
    <configuration>
        <systemPropertyVariables>
            <org.vanilladb.core.config.file>${project.build.directory}/test-classes/org/vanilladb/core/vanilladb.properties</org.vanilladb.core.config.file>
            <java.util.logging.config.file>${project.build.directory}/test-classes/java/util/logging/logging.properties</java.util.logging.config.file>
        </systemPropertyVariables>
        <forkCount>1</forkCount>
        <argLine>--add-modules jdk.incubator.vector</argLine>
        <includes>
            <include>org/vanilladb/core/FullTestSuite.java</include>
        </includes>
    </configuration>
</plugin>

3. 调整运行命令的参数顺序

java命令中-jar参数必须紧跟jar文件名,其他参数需放在-jar之前,修正后的运行命令:

java --add-modules=jdk.incubator.vector -Djava.util.logging.config.file=logging.properties -Dorg.vanilladb.bench.config.file=vanillabench.properties -Dorg.vanilladb.core.config.file=vanilladb.properties -jar server.jar baseline_DB

4. IDE环境补充配置(如果使用IDE开发)

若在IDE中编译,需手动添加模块参数:

  • 以IntelliJ IDEA为例:打开File → Project Structure → Modules,选中目标模块,点击Dependencies标签,添加JDK安装目录下的jmods/jdk.incubator.vector.jmod作为依赖;或者在Compiler → Java Compiler的Additional command line parameters中添加--add-modules jdk.incubator.vector

验证流程

  1. 执行mvn clean compile检查编译是否通过
  2. 执行mvn test确认测试正常运行
  3. 打包后用修正后的命令启动程序,验证功能正常

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.18 12:02:30