Nexus 学习记录 2 - Maven本地仓库

1. 配置仓库

选择proxy类型,将 https://repo1.maven.org/maven2/ 设为远程仓库

也可将proxy、hosted加入到group中。

2. 下载jar包,对单个项目起作用

# 在单个项目的pom.xml 加入
 <repositories>
     <repository>
        <id>central</id>
         <name>central</name>
         <!-- http://r123m:8002/repository/maven-public/ -->
        <url>http://r123m:8002/repository/maven-central/</url>
     </repository>
  </repositories>

3. 下载jar包,对所有项目起作用

# 对setting.xml中设置
<mirror>
    <id>nexus-get</id>
    <name>nexus-get</name>
    <url>http://r123m:8002/repository/maven-public/</url>
    <mirrorOf>central</mirrorOf>
</mirror>

4. 命令上传jar包

  • 一般上传至hosted仓库类型完成。
  • pom.xml设置
<distributionManagement>
   <!-- #发布版本的仓库  -->
    <repository>
      <id>release</id>
      <name>release</name>
      <url>http://r123m:8002/repository/maven-releases/</url>
    </repository>

   <!-- #快照版本的仓库  -->
    <snapshotRepository>
      <id>snapshot</id>
      <name>snapshot</name>
      <url>http://r123m:8002/repository/maven-snapshots/</url>
    </snapshotRepository>
  </distributionManagement>
  • setting.xml设置
#添加nexus的用户密码
#里面的id与pom.xml中的distributionManagement中repository的id要相同
<server>
   <id>release</id>
   <username>admin</username>
   <password>123456</password>
</server>

<server>
    <id>snapshot</id>
    <username>admin</username>
    <password>123456</password>
</server>
  • 右击项目-> Run as -> maven build ... -> 在goals输入deploy,运行

5. 手动上传

  • 在nexus中upload中上传,地址 maven-release,类型hosted
  • classifier通常用于区分从同一POM构建的具有不同内容的构件(artifact)。它是可选的,它可以是任意的字符串,附加在版本号之后。如 test、source

6. 常用的第三方Repository

# 1. 
https://repository.cloudera.com/artifactory/cloudera-repos/

# 2. 是第一个的子集
https://repository.cloudera.com/cloudera/cdh-releases-rcs/  

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值