Maven 无效目标发布:13

问题描述

我在 Eclipse 中使用 Maven,我想用 Java13 运行我的项目。每次我构建我的项目时,我都会收到以下错误消息:

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project subscriptionsmanager: Fatal error compiling: invalid target release: 13 -> [Help 1]

我在 <properties> 中配置了我的 pom.xml 文件,如下所示:

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>13</maven.compiler.source>
<maven.compiler.target>13</maven.compiler.target>

从 Eclipse 的“Java 构建路径”部分将 Java13 作为 JRE 来自 Eclipse。

enter image description here

有没有我没有考虑过的设置?

解决方法

正如 naman 所建议的,您需要显式配置您的 Maven 编译器插件:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>13</source>
                <target>13</target>
            </configuration>
        </plugin>
...