1、配置本地仓库
<localRepository>D:\Program Files\repository</localRepository>
2、配置远程仓库的服务器的验证信息
<servers>
<server>
<id>nexus-releases</id>
<username>deployment</username>
<password>deployment@123</password>
</server>
<server>
<id>nexus-snapshot</id>
<username>deployment</username>
<password>deployment@123</password>
</server>
</servers>
3、配置镜像:通过远程仓库的id拦截指定远程仓库的请求,将其转到镜像网站
id:镜像的唯一标识
mirrorof:通过id指哪个远程仓库被镜像了
name:名字,可以说明镜像的作用
url:镜像仓库的地址
<mirrors>
<!--镜像
id:镜像的唯一标识
mirrorof:通过id指哪个远程仓库被镜像了
name:名字,可以说明镜像的作用
url:镜像仓库的地址
-->
<mirror>
<id>nexus-center</id>
<mirrorOf>*</mirrorOf>
<name>Public Repositories</name>
<url>http://101.132.72.39:28881/nexus/content/groups/public/</url>
</mirror>
</mirrors>
4、配置远程仓库服务器,maven默认配置了中央仓库,在这里我们可以配置私服
<profiles>
<profile>
<id>snapshots-global</id>
<!--激活配置-->
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<!--远程仓库
id:远程仓库的唯一标识
name:名字,可以说明镜像的作用
url:远程仓库的地址
maven中的仓库分为两种,snapshot快照仓库和release发布仓库。
snapshot快照仓库用于保存开发过程中的不稳定版本,
release正式仓库则是用来保存稳定的发行版本。
定义一个组件/模块为快照版本,只需要在pom文件中在该模块的版本号
后加上-SNAPSHOT即可(注意这里必须是大写)
-->
<repository>
<id>nexus-center</id>
<name>nexus-center</name>
<url>http://101.132.72.39:28881/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<!--插件的远程仓库-->
<pluginRepository>
<id>nexus-center</id>
<name>nexus-center</name>
<url>http://101.132.72.39:28881/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
5、依赖的加载流程,先查询本地仓库,若本地仓库没有该依赖,则到注册且激活的远程仓库的查询,若此远程仓库被镜像了,则转而去镜像服务器查询,若镜像服务器没有该依赖,则去中央仓库查询,若中央仓库也被镜像了,则转而去相应的镜像服务器查询。注意中央仓库若被镜像了,则就算对应的镜像服务器挂了也不会中央仓库查询依赖。
6、nexus是唯一免费搭建maven仓库的软件