• Linux下安装Nexus3.x和maven简单使用


    一、简介

      Nexus是一个强大的Maven仓库管理器,它极大地简化了自己内部仓库的维护和外部仓库的访问。

    二、安装

      1、需要jdk8以上环境

      2、下载Nexus安装包,下载官网地址:https://www.sonatype.com/download-oss-sonatype

      3、安装只需要几步即可

    sudo mkdir /opt/nexus
    # 解压
    sudo tar zxvf nexus-3.13.0-01-unix.tar.gz  -C  /opt/nexus
    # 新建用户
    sudo useradd nexus
    # 修改文件所属用户
    sudo chown nexus /opt/nexus -R 
    # 添加java配置
    # 将INSTALL4J_JAVA_HOME_OVERRIDE=/opt/java/jdk1.8.0_171/
    vi /opt/nexus/nexus-3.13.0-01/bin/nexus

      4、第一次启动查看日志,之后可以使用(启动:/opt/nexus/nexus-3.13.0-01/bin/nexus start 关闭:/opt/nexus/nexus-3.13.0-01/bin/nexus stop

    /opt/nexus/nexus-3.13.0-01/bin/nexus run

      5、启动完成后访问地址:http://127.0.0.1:8081(如果出现页面中404错误,等会在刷新访问)

      6、使用默认账号:admin/admin123登陆

    三、maven使用

    1、在maven的配置文件settings.xml中添加

    <servers>
            <server>
                <id>maven-releases</id>
                <username>admin</username>
                <password>admin123</password>
            </server>
            <server>
                <id>maven-snapshots</id>
                <username>admin</username>
                <password>admin123</password>
            </server>
    </servers>
    View Code

    2、在pom.xml添加,可以使用mvn deploy上传

     <!--发布管理 需要配置在setting文件配置server-->
        <distributionManagement>
            <repository>
                <id>maven-releases</id>
                <name>Nexus ReleaseRepository</name>
                <url>http://localhost:8081/repository/maven-releases/</url>
            </repository>
            <snapshotRepository>
                <id>maven-snapshots</id>
                <name>Nexus SnapshotRepository</name>
                <url>http://localhost:8081/repository/maven-snapshots/</url>
            </snapshotRepository>
        </distributionManagement>
    
        <!--直接在pom中使用仓库-->
        <repositories>
            <repository>
                <id>maven-releases</id>
                <name>Nexus ReleaseRepository</name>
                <url>http://localhost:8081/repository/maven-releases/</url>
                <releases><enabled>true</enabled></releases>
                <snapshots><enabled>false</enabled></snapshots>
            </repository>
            <repository>
                <id>maven-snapshots</id>
                <name>Nexus SnapshotRepository</name>
                <url>http://localhost:8081/repository/maven-snapshots/</url>
                <releases><enabled>false</enabled></releases>
                <snapshots><enabled>true</enabled></snapshots>
            </repository>
        </repositories>

     3.使用仓库也可以setting文件中配置,snapshots所在的jar不能直接下载(也可以直接私服上更改属性),打jar包版本建议使用releases后缀上传到releases仓库(上传后该版本不可更改)

    <profiles>
            <profile>
                <id>nexus</id>
                <repositories>
                    <repository>
                        <id>central</id>
                        <url>http://localhost:8081/repository/maven-public/</url>
                        <releases>
                            <enabled>true</enabled>
                        </releases>
                        <snapshots>
                            <enabled>true</enabled>
                        </snapshots>
                    </repository>
                    <repository>
                        <id>aliyun</id>
                        <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
                    </repository>
                </repositories>
            </profile>
        </profiles>
        <activeProfiles>
            <activeProfile>nexus</activeProfile>
        </activeProfiles>

    yexiangyang

    moyyexy@gmail.com


  • 相关阅读:
    web框架学习
    css上
    数据库
    线程
    反射以及部分内置方法
    排序函数sort() 和sorted() 之介绍
    类的绑定方法
    继承
    面向对象和类
    混淆矩阵、准确率、召回率
  • 原文地址:https://www.cnblogs.com/moy25/p/9610635.html
Copyright © 2020-2023  润新知