Maven私服的使用

本地项目配置引用私服

一. 自动发布构件到远程仓库 
1. 在工程的pom.xml中添加:

<distributionManagement>

    <repository>
           <id>releases</id><!--这个ID需要与你的release仓库的Repository ID一致-->
           <url>http://172.18.19.157:8081/nexus/content/repositories/releases</url>
    </repository>
    <snapshotRepository>
        <id>snapshots</id><!--这个ID需要与你的snapshots仓库的Repository ID一致-->
        <url>http://172.18.19.157:8081/nexus/content/repositories/snapshots</url>
    </snapshotRepository>

</distributionManagement>
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

2.修改$MAVEN_HOME\conf目录下的settings.xml配置文件,添加如下配置:

<servers>
     <server>
        <id>releases</id>
        <username>admin</username>
        <password>dev123</password>
    </server>
    <server>
        <id>snapshots</id>
        <username>admin</username>
        <password>dev123</password>
    </server>
  </servers>
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

3.打开windows命令行,在工程所在目录下执行

mvn deploy
 
 
  • 1
  • 1

所部署的包就自动上传到了nexus安装目录下的 
这里写图片描述

二.配置Maven从Nexus下载构件 
1.在POM中配置Nexus私服,这样的配置只对当前的Maven项目有效。

<repositories>
      <repository>
          <id>public</id>
          <name>Team Maven Repository</name>
          <url>http://172.18.19.157:8081/nexus/content/groups/public/</url>
          <releases>
              <enabled>true</enabled>
          </releases>
          <snapshots>
              <enabled>true</enabled>
          </snapshots>
      </repository>
  </repositories>
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

2.在settings.xml中配置profile元素,这样就能让本机所有的Maven项目都使用自己的Maven私服。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值