Maven的基本知识
- 中央仓库:目前来说,
http://repo1.maven.org/maven2/
是真正的Maven中央仓库的地址,该地址内置在Maven的源码中,其它地址包括著名的ibiblio.org
,都是镜像。 - 索引:中央仓库带有索引文件以方便用户对其进行搜索,索引每周更新一次,下面附IDEA更新索引的步骤。
- 本地仓库:本地仓库可以看做是中央仓库的一个子集或者缓冲区,查找依赖时候,会先查找本地仓库,没有的话再去中央仓库查找。
IDEA更新索引
打开IDEA,Setting>Build,Execution,Deployment>Build Tools>Maven>Repository,点击点击Type为Remote的进行Update,即可更新索引
改用阿里云镜像
- maven 配置文件配置settings.xml中设置mirror节点
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
- pom.xml 配置repository节点
<repositories>
<repository>
<id>nexus-aliyun</id>
<name>Nexus aliyun</name>
<layout>default</layout>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>