问题
使用idea在增加的时候提示慢,或者没有提示,导致我们编辑pom文件的时候很烦.
idea可以通过依赖索引提供依赖提示的功能:
idea 配置快速索引
Ctrl+Alt +S 打开settiings
按照上图操作 点击 update 即可.
导致update Remote error 的原因
我们知道apache-maven的settings.xml不做任何配置时是有默认的仓库的,这个仓库就是central仓库,默认值是https://repo.maven.apache.org/maven2/,我们可以配置mirrorOf=central只镜像默认的central仓库。
一般情况下我们会配置阿里云镜像仓库加速依赖下载,在Maven的settings.xml文件下设置来指定镜像仓库
但是阿里云镜像仓库不支持依赖索引,导致我们索引更新失败. error警报.
IntelliJ Maven error: Repository is non-nexus repo, or is not indexed (remote update error)
解决办法
1.直接使用是Maven的中央仓库,进行索引加载(过程很慢文件太多了)
<mirror>
<id>central</id>
<mirrorOf>*</mirrorOf>
<name>manve2</name>
<url>https://repo.maven.apache.org/maven2</url>
</mirror>
2. 没有网络的情况下可以把中央仓库的索引下载到本地,进行本地加载
一共分为两个步骤
- 第一步: 下载索引
- 第二部:这只本地镜像加载索引
下面介绍下流程
- 下载索引
转到 https://repo.maven.apache.org/maven2/.index/ 下载6个文件 到本地:
nexus-maven-repository-index.gz
nexus-maven-repository-index.gz.md5
nexus-maven-repository-index.gz.sha1
nexus-maven-repository-index.properties
nexus-maven-repository-index.properties.md5
nexus-maven-repository-index.properties.sha1
这里我下载到了f盘 maven2/.index 文件夹下
注意: 文件夹一定要和上图保持一致. - 配置settings.xml 文件
<mirror>
<id>default</id>
<mirrorOf>central</mirrorOf>
<name>local</name>
<url>file://F:maven2/</url>
</mirror>
- 重启idea 然后update索引
更新完毕
4.更新完记得恢复settings文件
好了,现在就可以快速索引了