zoukankan      html  css  js  c++  java
  • Nexus 安装运维手册

    1. Nexus 安装与配置

    1.1 下载Nexus

      登录https://www.sonatype.com/download-oss-sonatype,下载最新的Nexus版本。 我这里使用的是nexus-3.16.1-02版本;

    1.2 安装Nexus

    #将tar包上传到服务器/usr/local/目录下解压,这个时候会出现 nexus-3.16.1-02、sonatype-work 两个文件夹
    
    tar -zxvf nexus-3.16.1-02-unix.tar.gz  
    
    #修改配置文件,eg:端口号
    
    cd /usr/local/nexus-3.16.1-02/etc
    
    vim nexus-default.properties

    1.3 启动Nexus

      启动用户是root的时候会出现下面的警告,可以通过修改/usr/local/nexus-3.16.1-02/bin/nexus.rc文件解决;

           

    #修改启动用户run_as_user,建议不要使用root
    
    vim /usr/local/nexus-3.16.1-02/bin/nexus.rc
    
    #
    cd /usr/local/nexus-3.16.1-02/bin
    
    ./nexus start --后台启动
    
    ./nexus run --前台启动,显示日志

    1.4 登录Nexus

      服务启动完以后,输入Ip地址+端口访问(8081),Nexus默认的账户名和密码是是 admin/admin123

    1.5 配置私有库

      将私有库添加到http://192.168.209.128:8081/repository/maven-public/中。

    1.6 导入jar包

      一般私服都是存在内网环境,Nexus3.0以后需要通过命令命令将具体的jar包打到私服中;

    #将下面的脚本丢到需要上传jar包的文件目录下
    chmod u+x mavenimport.sh
    ./mavenimport.sh -u admin -p admin123 -r http://192.168.209.128:8081/repository/lingan/
    #!/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}/{} ;

    1.7 设置登录用户权限

      建议将admin注销,重新定义一个登录用户。在Nexus 3.0 这个版本中我直接删除admin会报错,但是设置为不可用没有问题;

    2. Maven 安装与配置

    2.1 下载Maven

          登录http://maven.apache.org 下载最新的maven版本,我这里使用的是apache-maven-3.6.1版本。

    2.2 安装Maven

    将tar包上传到服务器/usr/local/目录下解压
    tar -zxvf apache-maven-3.6.1-bin.tar.gz 
    

    2.3 配置Maven

    #配置release、snapshot的用户信息;
    #配置mirror指向私服的nexus-public;
    vim /usr/local/maven/apache-maven-3.6.1/conf/setting.xml
    

    3. 工作空间配置

    3.1 修改本地Maven配置

      配置release、snapshot的用户信息;

      配置mirror指向私服的nexus-public;

    3.2 修改工程中的pom文件

    <repositories>

        <repository>

            <id>nexus-public</id>

            <url>http://192.168.11.23:8180/repository/maven-public/</url>

            <snapshots>

                <enabled>true</enabled>

            </snapshots>

        </repository>

    </repositories>

    <distributionManagement>

        <repository>

            <id>release</id>

            <url>http://192.168.11.23:8180/repository/maven-releases/</url>

        </repository>

        <snapshotRepository>

            <id>snapshot</id>

            <url>http://192.168.11.23:8180/repository/maven-snapshots/</url>

        </snapshotRepository>

    </distributionManagement>

    <build>

        <plugins>

            <plugin>

                <groupId>org.apache.maven.plugins</groupId>

                <artifactId>maven-compiler-plugin</artifactId>

                <version>3.8.0</version>

                <configuration>

                    <source>1.7</source>

                    <target>1.7</target>

                    <encoding>UTF-8</encoding>

                </configuration>

            </plugin>

            <plugin>

                <groupId>org.apache.maven.plugins</groupId>

                <artifactId>maven-war-plugin</artifactId>

                <version>3.2.2</version>

            </plugin>

        </plugins>

    </build>

      

  • 相关阅读:
    BZOJ 3261 最大异或和(可持久化Trie)
    模板 普通平衡树
    HDU4825 Xor Sum(贪心+Trie树)
    二维LIS(CDQ分治)
    IOIOI卡片占卜(Atcoder-IOIOI カード占い)(最短路)
    USACO 2009 Dec cow toll paths 过路费-floyd
    [USACO08JAN]电话线Telephone Lines(分层图)/洛谷P1948
    lightoj 1038 Race to 1 Again 期望
    lightoj 1030 Discovering Gold 期望
    lightoj 1027 A Dangerous Maze 期望
  • 原文地址:https://www.cnblogs.com/jiangyaxiong1990/p/10813110.html
Copyright © 2011-2022 走看看