关于nexus:离线安装Nexus

26次阅读

共计 1924 个字符,预计需要花费 5 分钟才能阅读完成。

前置要求

零碎先装置 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 section
application-port=8003
application-host=0.0.0.0
nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml
nexus-context-path=/

# Nexus section
nexus-edition=nexus-pro-edition
nexus-features=\
 nexus-pro-feature

nexus.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 mavenRepository
cd 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 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}/{} ;

给脚本赋予可执行权限

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 包文件存在

正文完
 0