描述:本文主要是基于Linux系统实现本地jar包上传至nexus私仓
https://www.sonatype.com/nexus/repository-oss/download
地址:http://192.168.1.5:8081/ 登录名:admin 密码:admin123
点击登录,按照页面提示填写用户名密码,然后修改默认密码。登录成功后,页面有个红色感叹号,提 示linux系统的文件描述符太小,建议设置大一点。
sudo vi /etc/security/limits.conf #最后添加下面两行 * soft nofile 65536 * hard nofile 65536重启或切换下用户登录即可生效
#切换用户 su root #查看是否生效,结果应为刚刚修改的65536 ulimit -n本文建一个maven仓库存储目录为例,后续可以为不同的仓库建立不同的存储目录
创建成功。
创建成功。
将需要传至nexus私仓的本地maven仓库(包括目录)同步到Linux服务器,本文上传至/home/cc/data/relaese/
在maven仓库目录即/home/cc/data/relaese/下建立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}/{};赋予mavenimport.sh执行权限
chmod u+x mavenimport.sh执行mavenimport.sh文件,格式:./mavenimport.sh -u [用户名] -p [密码] -r [仓库地址]
./mavenimport.sh -u admin -p admin123 -r http://192.168.1.5:8081/repository/credit-chain/检查nexus仓库是否正确
成功上传至私仓。
可以看到maven从私仓http://192.168.1.5:8081/repository/maven-group/中拉取依赖jar包。
