我正在尝试将项目迁移到 Java 12,使用--enable-preview
.
我--enable-preview
在编译器设置中添加:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>12</release>
<compilerArgs>
<arg>--enable-preview</arg>
</compilerArgs>
</configuration>
</plugin>
并且还在 argLine 中添加了它以确保万无一失和故障安全:
<properties>
<argLine>--enable-preview</argLine>
</properties>
并做一个mvn clean verify
结果:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:test (default-test) on project lombok-jdk10: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:test failed: java.lang.UnsupportedClassVersionError: Preview features are not enabled for com/kirela/lombok/BarTest (class file version 56.65535). Try running with '--enable-preview' -> [Help 1]
我也尝试将 argLine 直接添加到 surefire/failsafe 配置中,但结果是一样的。
我在这里想念什么?
我这是万无一失/故障安全中的一个错误?
EDIT2:Surefire 和故障安全配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<forkCount>2</forkCount>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M3</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<forkCount>2</forkCount>
</configuration>
</plugin>
EDIT3:最小的工作示例在这里:https ://github.com/krzyk/lombok-jdk10-example
该项目失败--enable-preview
,但当我删除它时工作。