安装本地私服nexus。
去官网上下载nexus,然后在环境变量中配置,如图:
然后通过cmd操作,安装和启动。
安装好以及启动之后,我们便可以通过http://localhost:8081/nexus/index.html
访问nexus主页了。
Nexus其实就是一个本地的工厂,我们可以通过它下载我们所需要的jar包到我们本地,这样我们自己就可以管理所需要的jar,同时保存下曾经用过的jar,不用每次都是maven的中央工厂里面下载。
下面是如何配置nexus。
第一种方法:
我们可以通过项目的pom.xml配置。如下:
<!-- 配置本地仓库,本地私有服务器nexus -->
<!-- <repositories>
<repository>
<id>nexus</id>
<name>Nexus Repository</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories> -->
用这种方法的话,我们在每个项目中都需要配置,显得比较麻烦。下面我们推荐一种很方便的方法,那就是在maven中配置,只需要配置一次,以后每个项目就不需要配置了。
第二种:
我们找到maven的setting.xml。配置如下:
<!-- 配置本地仓库,本地私有服务器nexus -->
<proxy>
<id>nexusRepo</id>
<repositories>
<repository>
<id>nexus</id>
<name>Nexus Repository</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</proxy>
</proxies>
<!-- 只有激活才生效-->
<activeProfile>nexusRepo</activeProfile>
这样我们就不用去一个一个项目里面配置了。
当我们能够在nexus中下载到我们所需的jar时候,那系统就会自动在nexus的仓库里面下载,如果下载不到,或者是nexus没启动的话,则会自动转回到maven的中央仓库去下载。
<mirror>
<id>nexusMirror</id>
<mirrorOf>nexus,central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
</mirror>
</mirrors>
Maven学习笔记之mavne的仓库---私服,布布扣,bubuko.com
原文:http://blog.csdn.net/fangleijiang/article/details/20242029