maven将本项目提交到nexus

将本项目提交到nexus

本地maven setting.xml

</servers>
     <server>
        <id>geovis</id>
        <username>admin</username>
        <password>icenter123</password>
    </server>
	
    <server>
        <id>releases</id>
        <username>admin</username>
        <password>icenter123</password>
    </server>

    <server>
        <id>snapshots</id>
        <username>admin</username>
        <password>icenter123</password>
    </server>
 </servers>

项目pom

<!-- 使用分发管理将本项目打成jar包,直接上传到指定服务器 -->
<distributionManagement>
    <repository>
        <!-- nexus服务器中用户名:在settings.xml中<server>的id-->
        <id>releases</id>
        <!-- 这个名称自己定义 -->
        <name>Releases</name>
        <url>http://192.168.71.62:8081/repository/maven-releases/</url>
    </repository>
</distributionManagement>

提交命令

# -e 为打印日志,打印更详细日志可用 -X
mvn clean deploy -e

将单个依赖提交到nexus,DrepositoryId对应账号密码,账号密码配置与上方一样

将多个依赖提交到nexus
在nexus上新建一个respository,将新包上传到这个respository上,防止意外

在公网上将项目依赖拉到本地电脑的 respository,将此目录打包并上传到服务器上,再解压到respository,进入repository
vi mavenimport.sh

#!/bin/bash
# copy and run this script to the root of the repository directory containing files
# this script attempts to exclude uploading itself explicitly so the script name is important
# Get command line params

while getopts ":r:u:p:" opt; do
        case $opt in
                r) REPO_URL="$OPTARG"
                ;;
                u) USERNAME="$OPTARG"
                ;;
                p) PASSWORD="$OPTARG"
                ;;
        esac
done

find . -type f -not -path './mavenimport\.sh*' -not -path '*/\.*' -not -path '*/\^archetype\-catalog\.xml*' -not -path '*/\^maven\-metadata\-local*\.xml' -not -path '*/\^maven\-metadata\-deployment*\.xml' | sed "s|^\./||" | xargs -I '{}' curl -u "$USERNAME:$PASSWORD" -X PUT -v -T {} ${REPO_URL}/{} ;

chmod a+x mavenimport.sh
启动脚本

./mavenimport.sh -u admin -p icenter123 -r http://192.168.21.62:8081/repository/maven-upgrade/

将nexus上新建的respository,关联并应用

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值