首先访问 Nexus 页面,登录后点击“Create repository”按钮新建一个仓库
(2)选择 maven2(hosted)
按照自身需求填写如下选项(仓库名随意):
(4)在服务器 /home 目录下,新建一个文件夹 myrepo,将本地仓库的包批量放入我们需要的本地库文件夹,注意必须将package层级都拷贝,有多本地时,eclipse可以本地切换分支install多次,将生成多个版本的jar
(5)在 repo 文件夹下执行如下命令创建一个 shell 脚本:mavenimport.sh
chmod +x mavenimport.sh
执行导入
./mavenimport.sh -u admin -p 123 -r http://192.168.60.133:8081/repository/my_repo/
注意:http://192.168.60.133:8081/repository/my_repo/ 是仓库地址
#!/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}/{} ;