Maven 3.8.1 不支持 wrapperVersion,它必须至少为 4

wrapperVersion not supported for Maven 3.8.1, it must be at least 4

我正在为一个新的 Java 项目使用 Maven。使用 Maven 工件之一生成项目后,我尝试在项目内生成 Maven 包装器脚本。为此,我正在使用新的 Maven 插件和目标 wrapper:wrapper,但是我收到以下错误: Maven 3.8.1 不支持 wrapperVersion,它必须至少为 4

mvn wrapper:wrapper                                                                                                                      ⇣82.8 KiB/s ⇡2.76 KiB/s 192.168.2.110   77.29.199.151   100%  ─╯
[INFO] Scanning for projects...
[INFO] 
[INFO] ---------------------------< com.angel:demo >---------------------------
[INFO] Building demo 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-wrapper-plugin:3.0.2:wrapper (default-cli) @ demo ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.897 s
[INFO] Finished at: 2021-05-27T16:14:23+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-wrapper-plugin:3.0.2:wrapper (default-cli) on project demo: wrapperVersion not supported for Maven 3.8.1, it must be at least 4. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Java版本:

openjdk 11.0.11 2021-04-20 OpenJDK Runtime Environment (build 11.0.11+9) OpenJDK 64-Bit Server VM (build 11.0.11+9, mixed mode)

Maven 版本:

Apache Maven 3.8.1 (NON-CANONICAL_2021-04-26T21:52:54Z_root) Maven home: /opt/maven Java version: 11.0.11, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-11-openjdk Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.12.4-arch1-2", arch: "amd64", family: "unix"

OS 版本:Arch Linux Maven 应该包含从 Maven 3.7 开始的包装器脚本,这应该不是问题,因为我使用的是 Maven 3.8,但是版本 4 的错误消息让我感到困惑,我不知道在哪里寻找答案。

有时候答案就在眼前,但眼睛疲劳会让我们失明:D

正如@JFabianMeier 所说,没有 Maven 3.7,并且从 Maven 4.0 开始包含 Maven 包装器脚本

https://maven.apache.org/plugins/maven-wrapper-plugin/

对于您的项目,您仍然可以使用 Takari Maven Wrapper plugin。 Maven 版本低于 4.0.0 的任何项目都需要它。