前提:改好setting.xml的配置
- 某一天,我很快乐地下载好apache-maven-3.8.5-bin,很顺利地进入
K:\apache-maven-3.8.5-bin\apache-maven-3.8.5\conf
,打开settings.xml,修改好本地仓库配置和阿里云镜像配置:
本地仓库配置
<localRepository>K:\apache-maven-3.8.5-bin\apache-maven-3.8.5\maven-repo</localRepository>
阿里云镜像配置
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
- 我开心地开始在IDEA上配置maven。
File----->Settings搜索“maven”----->配置如下:
- 然后,我开心地开始新建Maven项目。
当然,项目非常顺利地创建成功了。但是,jar包全部下到默认仓库地址,也就是C盘了。这我能忍吗?不能!要都放C盘了,我建本地仓库干嘛?!于是,这就是问题一。
问题一:IDEA 2022.1.1改变仓库默认地址
解决问题也很简单:
(这和前面的配置好像有点像,我也不知道为啥)
- 好。我把下在C盘的jar包都删了,重新建一个Maven项目。于是,我很快遇到了第二个问题。
问题二:IDEA 2022.1.1新建Maven项目卡死
没错,它卡死了。因为archetype-catalog.xml文件太大,下载缓慢。
解决办法:下载archetype-catalog.xml文件并把它放到本地仓库目录下。
下载地址:https://repo1.maven.org/maven2/archetype-catalog.xml
跟着下图的地址放:
- 很好。这次,我退出项目,重新建Maven项目。
不卡死了。
于是,我遇到了第三个问题。
问题三:No archetype found in remote catalog. Defaulting to internal catalog
警告:
No archetype found in remote catalog. Defaulting to internal catalog
Archetype not found in any catalog. Falling back to central repository.
Add a repository with id ‘archetype’ in your settings.xml if archetype’s repository is elsewhere.
- 解决方法:添加配置参数
-DarchetypeCatalog=local
IDEA设置方法:
File-----> Other Settings-----> Settings for New Projects-----> Build,Execution,Deployment-----> Build Tools-----> Maven=> Runner----->
VM Options-----> 填写为“-DarchetypeCatalog=local”
- 没问题了。新建Maven项目成功。