我正在尝试使用 Java-13 和 Maven 创建 Java 模块项目。我pom.xml
的是:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>wtf.g4s8</groupId>
<artifactId>oot</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<junit-platform.version>5.3.1</junit-platform.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jdk.version>13</jdk.version>
</properties>
<dependencies>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit-platform.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-platform.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<target>${jdk.version}</target>
<source>${jdk.version}</source>
<release>${jdk.version}</release>
<useIncrementalCompilation>false</useIncrementalCompilation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
</plugin>
</plugins>
</build>
</project>
版本:
$ mvn help:system | grep -i jdk
sun.boot.library.path=/opt/jdk-13.0.1/lib
jdk.debug=release
java.home=/opt/jdk-13.0.1
java.runtime.name=OpenJDK Runtime Environment
java.vm.name=OpenJDK 64-Bit Server VM
JDK_HOME=/opt/jdk-13.0.1
JAVA_HOME=/opt/jdk-13.0.1
JAVAC=/opt/jdk-13.0.1/bin/javac
$ mvn -version
Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T22:00:29+03:00)
Maven home: /usr/share/maven-bin-3.6
Java version: 13.0.1, vendor: Oracle Corporation, runtime: /opt/jdk-13.0.1
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.3.2-gentoo", arch: "amd64", family: "unix"
如果我跳过测试阶段,它工作正常mvn clean package -DskipTests
:
建立成功
但是,当我尝试使用 测试项目时mvn clean test
,出现错误(完整日志在-e
这里:https ://gist.github.com/g4s8/a08e88143b7b5ceec0e534a34b7ab734 ):
[错误] 无法在项目 oot 上执行目标 org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:test (default-test):执行目标 org.apache.maven.plugins 的默认测试:maven-surefire-plugin:3.0.0-M3:test failed: Unsupported class file major version 57 -> [Help 1]
似乎surefire插件无法与13 JDK一起使用,但 插件文档说“要求:Maven 3.x和JDK 1.7或更高版本”(JDK 13高于JDK 1.7)。
那么我是否在我的pom.xml
插件中配置了一些错误或无法使用 13 JDK?
要重现的示例项目:https ://github.com/g4s8/so58710751