maven上传jar包到代码仓库

一、前言

    一般被引用的包开发都是要求放在nexus仓库中,等到有jar包服务需要引用该包的时候直接从nexus仓库中获取即可,实现了该引用包的公用

二、代码配置

    编辑代码中的pom.xml文件配置

    vi pom.xml

<distributionManagement>
    <repository>
        <id>nfd_nexus</id>   #自行命名id
        <name>nfd Repository</name>
        <url>http://10.1.60.112:8081/repository/nfd-releases/</url>  #使用nexus仓库的项目地址
    </repository>
    <snapshotRepository>
        <id>nfd_nexus</id>
        <name>nfd Snapshot Repository</name>
        <url>http://10.1.60.112:8081/repository/nfd-snapshots/</url> ##使用nexus仓库的项目地址
    </snapshotRepository>

</distributionManagement>

查看nexus仓库,复制项目存放目录的地址,粘贴到上面的配置中 

 这是配置好的pom.xml文件 

编辑maven的setting.xml配置文件,配置nexus仓库的账号密码

vi /etc/maven/apache-maven-3.9.0/conf/settings.xml

<servers>
  <server>
    <id>nfd_nexus</id>   #匹配上面的pom.xml的id
    <username>nfd</username>    #nexus仓库的用户名
    <password>11111111</password>  #nexus仓库的密码
  </server> 
</servers>

至此配置完成

代码打包完成后执行以下命令推送 到nexus仓库即可

mvn deploy

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值