Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.4.0:generate (default-cli)

Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.4.0:generate (default-cli) on project standalone-pom: The plugin org.apache.maven.plugins:maven-archetype-plugin:3.4.0 requires Maven version 3.6.3 -> [Help 1]

这是由于 Maven 插件版本 与 Maven 主程序版本 不匹配导致的。

错误原因

插件 maven-archetype-plugin:3.4.0 要求 Maven 的最低版本为 3.6.3,而当前使用的 Maven 版本低于此要求。

方法一:升级 Maven 至 3.6.3 或更高版本

  • 下载最新的 Maven: 前往 Maven 官方下载页面。 下载 apache-maven-3.6.3-bin.zip 或更高版本。

  • 解压文件并配置环境变量: 设置 MAVEN_HOME 为解压路径。 确保 Path 中包含 %MAVEN_HOME%\bin。

  • 验证安装:

mvn -v

方法二:降低插件版本

如果无法升级 Maven,可以修改项目的 pom.xml 文件,将插件版本降级到与当前 Maven 兼容的版本。例如:

<build>

<plugins>

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-archetype-plugin</artifactId>

<version>3.2.1</version> <!-- 使用兼容的较低版本 -->

</plugin>

</plugins>

</build>

我使用方法二

C:\Users\VICTUS\.jdks\ms-17.0.15\bin\java.exe -Dmaven.multiModuleProjectDirectory=C:\Users\VICTUS\AppData\Local\Temp\archetypetmp -Djansi.passthrough=true -Dmaven.home=F:\maven\maven3.6\maven3.6 -Dclassworlds.conf=F:\maven\maven3.6\maven3.6\bin\m2.conf -Dmaven.ext.class.path=D:\文件\ideaIU-2023.3.6.win\plugins\maven\lib\maven-event-listener.jar -javaagent:D:\文件\ideaIU-2023.3.6.win\lib\idea_rt.jar=7504:D:\文件\ideaIU-2023.3.6.win\bin -Dfile.encoding=UTF-8 -classpath F:\maven\maven3.6\maven3.6\boot\plexus-classworlds-2.6.0.jar org.codehaus.classworlds.Launcher -Didea.version=2023.3.6 -s F:\maven\maven3.6\maven3.6\conf\settings.xml -DinteractiveMode=false -DgroupId=com.itheima -DartifactId=CY_HiveDemo -Dversion=1.0-SNAPSHOT -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.1 org.apache.maven.plugins:maven-archetype-plugin:RELEASE:generate [INFO] Scanning for projects... [INFO] [INFO] ------------------< org.apache.maven:standalone-pom >------------------- [INFO] Building Maven Stub Project (No POM) 1 [INFO] --------------------------------[ pom ]--------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.098 s [INFO] Finished at: 2025-07-09T15:04:04+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.4.0:generate (default-cli) on project standalone-pom: The plugin org.apache.maven.plugins:maven-archetype-plugin:3.4.0 requires Maven version 3.6.3 -> [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/PluginIncompatibleException Process finished with exit code 1
07-10
使用命令行创建多模块项目 创建父项目: 使用以下命令创建父项目: Bash mvn archetype:generate \ -DgroupId=com.example \ -DartifactId=my-multi-module \ -DarchetypeArtifactId=maven-archetype-quickstart \ -DinteractiveMode=false 删除父项目的 src 目录: Bash rm -rf my-multi-module/src 创建子模块: 进入父项目目录,并创建子模块: Bash cd my-multi-module mvn archetype:generate \ -DgroupId=com.example \ -DartifactId=module1 \ -DarchetypeArtifactId=maven-archetype-quickstart \ -DinteractiveMode=false Bash mvn archetype:generate \ -DgroupId=com.example \ -DartifactId=module2 \ -DarchetypeArtifactId=maven-archetype-quickstart \ -DinteractiveMode=false 修改父项目的 pom.xml 文件,添加 <modules> 配置: XML <modules> <module>module1</module> <module>module2</module> </modules> 配置父 POM 和子模块 POM: 父项目的 pom.xml 文件中定义 <dependencyManagement> 和 <pluginManagement>。 子模块的 pom.xml 文件中添加 <parent> 配置,继承父项目的公共依赖和插件。 验证模块是否成功继承 检查子模块的 pom.xml 文件: 确保子模块中正确声明了 <parent> 配置。 子模块的 pom.xml 文件应包含父 POM 中定义的依赖和插件。 使用 Maven 命令验证构建: 在父项目目录下运行以下命令,验证整个项目的构建是否成功: Bash mvn clean install 检查依赖关系: 使用 mvn dependency:tree 命令查看子模块的依赖树,确保所有依赖都已正确解析。 在该步骤中的创建子模块我报错了:[INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.855 s [INFO] Finished at: 2025-07-31T14:13:34+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.4.0:generate (default-cli) on project my-multi-module: Unable to add module to the current project as it is not of packaging type &#39;pom&#39; -> [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/MojoExecutionException
08-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

chde2Wang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值