Maven(3)——将本地文件推送到nexus中心库

  前一篇笔记说到了搭建 nexus 服务,作为开发的中心库。本篇就来简单的介绍一下将本地的文件(Jar)推送到搭建好的 nexus 服务中心库中。

  nexus服务配置

  在搭建号nexus服务中,有两个类型的库可以推送,分别是releases和snapshots,在本地搭建的nexus服务中,找到这两个库对应的URL

 http://localhost:8082/repository/maven-releases/
 http://localhost:8082/repository/maven-snapshots/

  获取该nexus的用户名和密码 admin、admin111 

  Maven 配置

  在安装好的maven服务中,找到settingxml 配置文件,作如下配置:

 

<servers>
      ...
      <server>
            <id>maven-releases</id>
            <username>admin</username>
            <password>admin123</password>
      </server>
      <server>
            <id>maven-snapshots</id>
            <username>admin</username>
            <password>admin123</password>
      </server>
      ...
</servers>>
  注意:其中的id与接下来的配置文件中的参数必须一一对应

  Maven推送

  在项目pom.xml文件中,做如下配置:

<distributionManagement>
      <repository>
        <id>maven-releases</id>
        <url>http://localhost:8082/repository/maven-releases/</url>
      </repository>
      <snapshotRepository>
        <id>maven-snapshots</id>
        <url>http://localhost:8082/repository/maven-snapshots/</url>
      </snapshotRepository>
    </distributionManagement>

配置完成后,回到该项目文件的根目录先后执行 maven clean install  / maven clean deploy


在一个团队合作开发中,公用一个远程中心库的话,可以很好的合作分工。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值