前置要求

零碎先装置jdk,参考Linux装置jdk。

装置Nexus

1.解压nexus安装包

tar -xvf nexus-3.35.0-02-unix.tar.gz

2.批改nexus-default.properties配置文件

默认配置也能够

# 批改配置,默认也能够vi nexus-3.35.0-02/etc/nexus-default.properties

配置内容如下:

## DO NOT EDIT - CUSTOMIZATIONS BELONG IN $data-dir/etc/nexus.properties### Jetty sectionapplication-port=8003application-host=0.0.0.0nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xmlnexus-context-path=/# Nexus sectionnexus-edition=nexus-pro-editionnexus-features=\ nexus-pro-featurenexus.hazelcast.discovery.isEnabled=true

启动Nexus

# 启动./nexus-3.35.0-02/bin/nexus start# 重启./nexus-3.35.0-02/bin/nexus restart# 进行./nexus-3.35.0-02/bin/nexus stop

应用Nexus

浏览器拜访:http://ip:port
点击右上角 Sign In 提醒你的admin用户的明码在服务器中的【/home/nexus/sonatype-work/nexus3/admin.password】
应用cat /home/nexus/sonatype-work/nexus3/admin.password 命令查看明码


启用匿名拜访

1.创立blob存储


2.创立hosted类型的maven



3.创立proxy类型的maven


name:proxy-maven
Remote storage:http://maven.aliyun.com/nexus/content/groups/public/

4.创立一个group类型的maven


name:group-maven

5.maven地方仓库地址

批量上传本地maven仓库到Nexus中

在nexus服务器中创立一个文件夹MavenRepository

mkdir mavenRepositorycd mavenRepository

上传本地maven仓库jar文件到MavenRepository目录下

在MavenRepository目录下创立脚本

vi 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 paramswhile getopts ":r:u:p:" opt; do    case $opt in        r) REPO_URL="$OPTARG"        ;;        u) USERNAME="$OPTARG"        ;;        p) PASSWORD="$OPTARG"        ;;    esacdone  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}/{} ;

给脚本赋予可执行权限

chmod +x mavenimport.sh

执行脚本开始上传
参数:
● -u:nexus用户名
● -p:nexus明码
● -r:创立hosted类型的maven仓库地址如下图:

./mavenimport.sh -u admin -p Nexus12345 -r http://192.168.28.150:8003/repository/maven-local/

查看nexus中是否有jar包文件存在