第一篇博客,有错误的地方,请大家多多指教。
看到网上很多小伙伴,在windows上搭建的最新版本Nexus3.x,优快云上有两篇文章介绍的都是linux上如何导入批量导入本地库,借鉴其经验,在windows10上测试通过,分享下。
说明:本文部分内容转载自(感谢如下两篇文章):
Nexus3.x 下载&安装&仓库使用:https://blog.youkuaiyun.com/weixin_42717648/article/details/98206733
Nexus3.x批量导入本地库:https://blog.youkuaiyun.com/u014468095/article/details/87261817
本文借鉴其经验后编写:
“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}/{} ;
前提:windows执行shell脚本,务必安装git 客户端工具。
1)mavenimport.sh需要在maven库目录下,如下图
Maven目录(待上传jar包集目录):F:\10Primeton_STUDIO\40eos_v5.0\00_PrimetonRepository
2)打开Git Bash 客户端命令工具,开始执行命令,如下图:
3)打开的窗口中,执行如下命令 :
./mavenimport.sh -u admin -p admin123 -r http://你的ip:你的端口/repository/my repo/
4)浏览器 打开Nexus3.x,查看仓库下的上传的jar包信息:(特别说明:此处我建的是EOSMS5)
5)上传前Maven仓库和上传后Nexus3.x对比图: