nexus内网新建Maven私库批量导入jar包

内容分享1个月前发布
0 0 0

背景:许多时候需要到内网调试,小伙伴们每次都要自己拷贝jar到内网,就想搭建一个内网的Maven仓库。
nexus安装这里就不多赘述了。

一.新建仓库

nexus内网新建Maven私库批量导入jar包

nexus内网新建Maven私库批量导入jar包

nexus内网新建Maven私库批量导入jar包

二.单个jar上传到仓库

这里不多说

nexus内网新建Maven私库批量导入jar包

三、批量导入

1.将本地repository压缩拷到linux服务器并解压
2.到解压的repository目录下新建脚本

vim ./import.sh

3.编写import.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  ./import.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}/{} ;

4.授权

chmod +x import.sh

5.执行脚本批量上传

./import.sh -u admin -p hnkcXXX -r http://68.156.178.23:8081/repository/hnkcRepository/

已经上传完毕了

nexus内网新建Maven私库批量导入jar包

6.修改Maven配置settings.xml文件

将配置的阿里云私库改成下面地址

nexus内网新建Maven私库批量导入jar包

<mirror>
    <id>alimaven</id>
    <mirrorOf>central</mirrorOf>
    <name>hnkc maven</name>
    <url>http://68.156.178.23:8081/repository/hnkcRepository/</url>
</mirror>

内网就可以正常下载jar包啦!

© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
none
暂无评论...