idea新建maven项目加载缓慢问题处理_archetypeCatalog

3 篇文章 0 订阅

问题描述: 
新建maven项目时,存在加载缓慢,或直接一直保持一个加载状态

问题原因: 
创建maven项目的时候,需要从http://repo.maven.apache.org/maven2/archetype-catalog.xml下载项目原型信息,访问外网,就可能存在类似问题。

================================================ 
ArchetypeCatalog介绍

The Archetype Plugin knows by default its internal catalog. It also knows about the local and remote catalogs:

local represents the ~/.m2/archetype-catalog.xml catalog file,

remote represents the 
http://repo.maven.apache.org/maven2/archetype-catalog.xml catalog file.

IDEA根据maven archetype的本质,其实是执行mvn archetype:generate命令,该命令执行时,需要指定一个archetype-catalog.xml文件。

该命令的参数-DarchetypeCatalog,可选值为:remote,internal ,local等,用来指定archetype-catalog.xml文件从哪里获取。

archetypeCatalog用来指定maven-archetype-plugin读取archetype-catalog.xml文件的位置:

internal——maven-archetype-plugin内置的

local——本地的,位置为~/.m2/archetype-catalog.xml

remote——指向Maven中央仓库的Catalog

默认为remote,从 
http://repo1.maven.org/maven2/archetype-catalog.xml下载archetype-catalog.xml文件。

解决方式:

从本地加载脚手架的配置文件
手动配置
全局配置
让maven使用国内镜像
从本地加载脚手架的配置文件
手动配置
新建project时,添加maven 属性:archetypeCatalog=internal

archetypeCatalog=internal 
 
结果如预期

全局配置
1、 先下载 archetype-catalog.xml 文件 
http://repo1.maven.org/maven2/archetype-catalog.xml

已经下载好的archetype-catalog.xml 
archetype-catalog.xml 
2. copy 此 archetype-catalog.xml 文件到本地仓库的 maven 下 catelog 的 jar 下面 

放这个位置,也没用 
 
-DarchetypeCatalog=local 


使用 -DarchetypeCatalog=local 配置 出现了这种情况,还是去网上下载了 

按照提示:-DarchetypeRepository=<your repository> 

-DarchetypeRepository=D:.m2\repository //全局配置推荐这个 

虽然出现了警告,无法连接这个仓库,之后调用默认的BasicRepositoryConnectorFactory,没有去访问外网,并BUILD SUCCESS

Cannot access D:\.m2\repository with type default using the available connector factories: BasicRepositoryConnectorFactory
1


-DarchetypeCatalog=internal//在有的情况下,是没有效果的

Other Settings 中的Default Settings ; 
更改项目的默认配置 


效果如预期,没有去访问外网,并BUILD SUCCESS 


手动配置命令

archetypeCatalog=internal
1
全局配置命令 
-DarchetypeRepository=<your repository>

====================================

让maven使用国内镜像
添加阿里云的mirror 
修改maven根目录下的conf文件夹中的setting.xml文件,内容如下:

<mirrors>
    <mirror>
      <id>alimaven</id>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
      <mirrorOf>central</mirrorOf>        
    </mirror>
  </mirrors>

mvn archetype:generate \
    -DgroupId=com.mycom.helloworld \
    -DartifactId=helloworld \
    -DarchetypeArtifactId=maven-archetype-quickstart \
    -DinteractiveMode=false \
-DarchetypeCatalog=http://maven.aliyun.com/nexus/content/groups/public/

详情查看: 
让maven使用国内镜像和archetypeCatalog

参考: 
IDEA新建MAVEN项目时速度缓慢 
[Maven]archetypeCatalog笔记
--------------------- 
原文:https://blog.csdn.net/icecoola_/article/details/78188504 
 

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值