1、私服的好处 :
如果没有配置私服的话。所有JAR都默认会去外网下载。如果项目组的人多。就会很慢,有的公司如果不能上外网的话。那所有JAR包都得不到了。如果本地仓库配置好后。项目中的所有JAR包都会先去这个库里取。因为是本地。所以会很快。没有网络也可以开发。

2、搭建步骤:

2.1 下载 nexus 版本号为2,下载这里就不说了(版本2和3有区别,这里使用2)。

2.2 安装 : 找到bin目录,先执行nexus install 安装到服务里,再执行 nexus start启动



注意 : 先要配置java路径,否则启动不成功见下图




3、访问

访问路径 : http://localhost:8081/nexus

4、项目中使用

在maven setting.xml中配置镜像


<mirrors>       <mirror>      <id>nexus-releases</id>
<mirrorOf>*</mirrorOf>         <url>
http://localhost:8081/nexus/content/groups/public
<http://localhost:8081/nexus/content/groups/public></url>       </mirror>
<mirror>         <id>nexus-snapshots</id>         <mirrorOf>*</mirrorOf>
<url>http://localhost:8081/nexus/content/groups/public-snapshots
<http://localhost:8081/nexus/content/groups/public-snapshots></url>
</mirror>  </mirrors>
这样本地每个项目就会到镜像中下载jar包。

5、Maven 本地仓库同步到私服中



把本地仓库中的jar包拷贝到私服
central(我的路径为D:\nexus\nexus-2.14.8-01-bundle\sonatype-work\nexus\storage\central)
中,




然后更新索引,不更新索引无效







  • « 上一篇:程序员如何搞定前端高频面试难题?附答案汇总 | 技术头条
  • » 下一篇:一文搞懂:词法作用域、动态作用域、回调函数、闭包
  •