侧边栏壁纸
博主头像
昂洋编程 博主等级

鸟随鸾凤飞腾远,人伴贤良品自高

  • 累计撰写 72 篇文章
  • 累计创建 79 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

批量上传本地maven库到Nexus服务器中

Administrator
2023-08-11 / 0 评论 / 0 点赞 / 111 阅读 / 0 字 / 正在检测是否收录...
温馨提示:
本文最后更新于2024-06-14,若内容或图片失效,请留言反馈。 部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

这是本地的maven库jar包
image-1691737510658
现在通过shell脚本批量上传nexus的maven-releases库中

Shell脚本

#!/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}/{} ;

保存此脚本文件比如touchmavenimport.sh,然后放到本地maven库最外层
image-1691737679612

批量上传

在脚本文件所在目录打开git命令窗口,因为windows是不能执行shell脚本的
image-1691737800287
然后执行下面命令

sh touchmavenimport.sh -u admin -p qq245700 -r http://127.0.0.1:8081/repository/maven-releases

可以看到在疯狂上传中
image-1691737992613

Maven安装私有jar到本地仓库

mvn install:install-file -Dfile=jta-1_0_1B.jar -DgroupId=javax.transaction -DartifactId=jta -Dversion=1.0.1B -Dpackaging=jar

Maven上传单个jar到Nexus

mvn deploy:deploy-file -DgroupId=javax.transaction -DartifactId=jta -Dversion=1.0.1B -Dpackaging=jar -Dfile=jta-1_0_1B.jar -Durl=http://192.168.0.112:8081/repository/maven-releases/ -DrepositoryId=maven-releases
0

评论区