在pom.xml中使用distributionManagement将项目打包上传到nexus私服

1、pom.xml文件添加distributionManagement节点

<!-- 使用分发管理将本项目打成jar包,直接上传到指定服务器 -->

  <distributionManagement>
    <!--正式版本-->
    <repository>
        <!-- nexus服务器中用户名:在settings.xml中<server>的id-->
        <id>yang</id>
        <!-- 这个名称自己定义 -->
        <name>Release repository</name>
        <url>http://192.168.1.105:8081/repository/yang/</url>
    </repository>
    <!--快照
    <snapshotRepository>
        <id>nexus-snapshots</id>
        <name>Snapshots repository</name>
        <url>http://192.168.1.105/repository/yang/</url>
    </snapshotRepository>-->
  </distributionManagement>

< repository >节点下的< id >对应setting.xml文件中的server的id

<!--maven连接nexus需要验证用户名和密码-->
    <server>
      <id>yang</id>
       <username>admin</username>
       <password>admin123</password>
     </server>

2、pom.xml中repositories标签的作用是: 用来配置maven项目的远程仓库。示例如下:

<repositories>
        <repository>
            <id>nexus</id>
            <name>Nexus Repository</name>
            <url>远程仓库地址</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>  <!--snapshots默认是关闭的,需要开启  -->
            </snapshots>
        </repository>
    </repositories>

按照上面配置是实现了配置maven项目的远程仓库,但是,这样的配置,如果我们创建一个项目,就需要配置一次,很麻烦。可以将上面的远程仓库配置在maven的setting.xml里面.这样就可以实现只配置一次

3、pom.xml中pluginRepository标签的作用是: 用来配置maven插件的远程仓库。示例如下:

<pluginRepositories>
        <pluginRepository>
            <id>nexus</id>
            <name>Team Nexus Repository</name>
            <url>远程仓库地址</url>
        </pluginRepository>
    </pluginRepositories>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值