第一步:首先创建一个shell脚本,你可以在本地先创建一个txt文件,然后复制下面的代码,保存后把后缀.txt改成.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}/{} ;
第二步:把你的shell脚本放到你本地的maven仓库的文件中,如下图:
然后右键单击,选择git bash here
最后运行以下指令即可:
./import.sh -u admin -p admin123 -r http://你的ip:你的端口/repository/my repo/
注意-r后面跟的是你的nexus仓库中你想存入的地址,自行查看。