Maven学习笔记之mavne的仓库---私服


安装本地私服 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 -->

<profile>
        <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>
    </profile>

  </profiles>
 <activeProfile>nexusRepo</activeProfile>


这样我们就不用去一个一个项目里面配置了。

当我们能够在nexus中下载到我们所需的jar时候,那系统就会自动在nexus的仓库里面下载,如果下载不到,或者是nexus没启动的话,则会自动转回到maven的中央仓库去下载。

 

设置镜像:工厂的镜像,只要mirror中的工厂要访问,都会自动来找镜像,如果镜像无法访问就不会再去中央工厂了,使用*表示所有的工厂使用这个镜像访问,这是推荐的做法。Setting.xml配置如下:

 <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>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值