这是我的 pom.xml:
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>13</source>
<target>13</target>
<release>13</release>
<compilerArgs>
--enable-preview
</compilerArgs>
</configuration>
</plugin>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<reuseForks>false</reuseForks>
<argLine>--enable-preview</argLine>
</configuration>
</plugin>
问题是构建正常,但是当启动测试时我得到:
[错误] 未能执行目标
org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M4:测试
项目 foo-project 上的 (default-test):执行目标的 default-test
org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M4:测试失败:
java.lang.UnsupportedClassVersionError:预览功能不支持
为 it/project/MyTest 启用(类文件版本 57.65535)。尝试
使用“--enable-preview”运行 -> [帮助 1]
我必须在 pom.xml 中插入什么才能在启用预览模式的情况下执行测试?
Thanks.
我有类似的问题。
- Maven版本:3.8.1
- 万火版本:2.22.2
- JK: 13
I used <reuseForks>true</reuseForks>
效果很好。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<release>${java.version}</release>
<showWarnings>true</showWarnings>
<compilerArgs>
<compilerArg>-Xlint:unchecked,deprecation</compilerArg>
<compilerArg>--enable-preview</compilerArg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.plugin.version}</version>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
<reuseForks>true</reuseForks>
<argLine>--enable-preview</argLine>
</configuration>
</plugin>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)