zoukankan      html  css  js  c++  java
  • 【转】将本地库批量导入到Nexus3.x上(Maven私服)

    1,问题描述

    (1)由于公司内网的 Nexus 私服仓库不能联网,不过本地仓库已经有很多的 maven 的 jar 包了,便想将其从本地仓库导入到 Nexus 私服中。

    (2)Nexus2.x 批量导入本地库是十分容易的,只需将库文件夹复制到对应 nexus 库下面,去网页刷新一下索引就OK了。在 Nexus3.x 中,我们没法这么操作了,但是我们可以使用 shell 脚本,批量导入 Nexus3.x。

    2,操作步骤

    (1)首先访问 Nexus 页面,登录后点击“Create repository”按钮新建一个仓库。

    (2)选择 maven2(hosted)

    (3)按照自身需求填写如下选项(仓库名随意):

    (4)在服务器 /home 目录下,新建一个文件夹 repo,批量放入我们需要的本地库文件夹:

    (5)在 repo 文件夹下执行如下命令创建一个 shell 脚本:

    (6)脚本内容如下:

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

    (7)保存退出后执行如下命令赋予其执行权限:

    chmod +x mavenimport.sh
    

    (8)执行如下命令即可将该目录下的 jar 包都导入到指定仓库中:

    ./mavenimport.sh -u admin -p 123 -r http://192.168.60.133:8081/repository/my_repo/
    

    注意:命令中 Nexus 用户名、用户密码、仓库地址根据实际情况进行修改。

    ./mavenimport.sh -u admin -p 123 -r http:

    (9)访问 Nexus 控制台页面,可以发现确实都上传成功了:

    转:http://m.hangge.com/news/cache/detail_2910.html

    好学若饥,谦卑若愚
  • 相关阅读:
    常见树的总结
    《深入理解Java虚拟机》读书笔记(第三章)
    《Jave并发编程的艺术》学习笔记(1-2章)
    Java多线程与并发之面试常问题
    Morris遍历-如何用空间复杂度O(1)来遍历二叉树
    BFPRT算法
    Manacher
    maven基础
    play framework + sbt入门之环境搭建
    rancher部署kubernets集群
  • 原文地址:https://www.cnblogs.com/wchw2008/p/15221304.html
Copyright © 2011-2022 走看看