b本地项目区下载架包的时候,顺序是:本地的仓库存储文件夹→本地私服(nexus)→中央仓库
我们可以在maven中的settings.xml中这样设置
<profiles>
<!--配置我们自己的工厂-->
<profile>
<id>nexusProfile</id>
<repositories>
<repository>
<id>test</id>
<name>nexus</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
<!-- 可以下载releases的架包,默认是打开的 -->
<releases>
<enabled>true</enabled>
</releases>
<!-- 可以下载snapshots的架包,默认是关闭的 -->
<snapshots>
<enabled>
true
</enabled>
</snapshots>
</repository>
</repositories>
</profile>
<!--这边重写了central的信息-->
<profile>
<id>mycentral</id>
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>http://rep</url>
<layout>default</layout>
<snapshots>
<!--原本默认是为false。现在修改成了true,架包中的配置就无效了@-->
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<!--进行激活上面的profile-->
<activeProfiles>
<activeProfile>mycentral</activeProfile>
</activeProfiles>
而且我们要设置一个镜像,使得,无论下载什么类型的架包,都会通过这个镜像来去我们本地私服去下载,如果下载不到的话,私服会自动的去中央仓库去下载
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
<!--工厂的镜像,只要mirrorof中的工厂要访问,就会自动来找镜像,如果镜像无法的访问就不会去中央工厂去下载了-->
<mirror>
<id>nexusMirror</id>
<!--使用*表示,所有的都来这边访问,这样的话就可以去掉activeProfiles了-->
<mirrorOf>*</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
</mirror>
</mirrors>
原文:http://www.cnblogs.com/fucktom/p/5429039.html