我试图弄清楚如何在我的Maven项目中使用jdk.incubator.vector
,但它总是返回以下错误:
Caused by: java.lang.Error: Unresolved compilation problems:
The import jdk.incubator cannot be resolved
The import jdk.incubator cannot be resolved
VectorSpecies cannot be resolved to a type
FloatVector cannot be resolved to a variable
VectorSpecies cannot be resolved to a type
DoubleVector cannot be resolved to a type
DoubleVector cannot be resolved
VectorSpecies cannot be resolved to a type
.....
这是我的pom.xml
文件:
<build>
<plugins>
<!-- Use JDK 17, instead of the default one (JDK 1.5) -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>17</release>
<compilerArgs>
<arg>--add-modules</arg>
<arg>jdk.incubator.vector</arg>
</compilerArgs>
</configuration>
</plugin>
<!-- Testing Settings -->
<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</argLine>
<argLine>jdk.incubator.vector</argLine>
<includes>
<include>org/vanilladb/core/FullTestSuite.java</include>
</includes>
</configuration>
</plugin>
....
然后我将代码编译成一个可运行的jar文件,并运行它。我的run参数如下所示:
java -jar --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 server.jar baseline_DB
我是Maven的新手,有人能帮我解决这个问题吗?先谢谢你了。
1条答案
按热度按时间8nuwlpux1#
surefire/failsafe/compiler插件的配置:
使用following versions of maven plugins:
Vector API示例(在JDK 21 ea build上运行):
你可以在这里找到一个完整的工作示例:https://github.com/khmarbaise/jdk21,在这个类中:https://github.com/khmarbaise/jdk21/blob/main/src/test/java/com/soebes/jdk21/incubator/VectorTest.java但是你必须安装最新的JDK 21 ea build。