初学MAVEN之mvn archetype:generate失败

本文记录了初学者在使用Maven时遇到的`mvn archetype:generate`命令失败的问题及解决过程。经过排查,问题出在网络连接上,无法访问中央仓库。通过切换到阿里云仓库成功解决了这个问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

跟着网上的教程学习maven。
第一步当然是安装和环境变量配置,相信大家都没有什么问题。值得一提的是,官方所提到的配置文件settings.xml的两个目录中,${maven.home}/conf/settings.xml的maven.home是你自己定义的环境变量目录,而${user.home}/.m2/settings.xml的user.home则是你请求命令时自动生成的目录,位置是C:\Users\用户名\.m2。这个小问题我倒是还纠结了一会,索性写出来。
安装成功后需要测试是否安装成功,在cmd操作台上面输入:mvn -v。有如下界面的表示maven安装成功。
在这里插入图片描述
第二步是,选择一个目录,建立项目原型。这一步需要获得与maven中央仓库的连接,从中央仓库下载jar依赖到本地仓库。在这里我没有修改settings.xml中关于本地仓库的配置,所以默认地址是${user.home}/.m2。我选择f盘下的一个目录操作。如下
在这里插入图片描述
到这里,基本上各种教程都会要求大家在cmd中输入:mvn archetype:generate。可是问题也出现在这里,无论我怎么尝试,命令操作都是失败的。

F:\demo>mvn archetype:generate
[INFO] Scanning for projects...
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-clean-plugin:2.5: Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-install-plugin:2.4: Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-install-plugin:jar:2.4
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-deploy-plugin/2.7/maven-deploy-plugin-2.7.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-deploy-plugin:2.7: Plugin org.apache.maven.plugins:maven-deploy-plugin:2.7 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-deploy-plugin:jar:2.7
Downloading from central: htt
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值