zoukankan      html  css  js  c++  java
  • Nexus3.6 window版私服搭建 安装、配置教程

    1、本地环境配置(Nexus3.6支持jdk版本1.6、1.7、1.8)

    这里写图片描述

    • 1.2、解压得到目录

    这里写图片描述

    • 1.3、将Nexus的bin目录添加到Path环境变量中:

    这里写图片描述

    • 1.4、安装启动

    打开cmd,一路cd到安装目录下的bin目录,输入命令:nexus /run 运行安装 
    注:如果出现错误:java.lang.NumberFormatException: null,则可能是jdk版本不对,或路径中带中文

    • 1.5、访问浏览器(http://localhost:8081) 
      到此配置完毕,然后,即可在本地访问Nexus,如出现下图就表示配置成功:

    这里写图片描述

    这里写图片描述

    2、Nexus中的仓库

    • 2.1、访问的仓库类型: 
           hosted 宿主仓库:主要用于部署无法从公共仓库获取的构件以及自己或第三方的项目构件; 
           proxy 代理仓库:代理公共的远程仓库; 
           group 仓库组:Nexus 通过仓库组统一管理多个仓库,这样我们在项目中直接请求仓库组即可请求到仓库组管理的多个仓库。

          简单的说,就是你可以上传私有的项目到hosted,以及配置proxy以获取第三方的依赖(比如可以配置中央仓库的地址)。前面两个都弄好了之后,在通过group聚合给客户提供统一的访问地址。

    • 2.2、管理本地仓库 
        Nexus预定义了2个本地仓库,分别是maven-releases, maven-snapshots, 分别讲一下这二个预置的仓库都是做什么用的: 
             maven-releases:这里存放我们自己项目中发布的构建, 通常是Release版本的。 
             maven-snapshots:这个仓库非常的有用, 它的目的是让我们可以发布那些非release版本, 非稳定版本。
    • 2.3、增加仓库(以增加宿主仓库为例)

    这里写图片描述

    这里写图片描述

    • 2.4、增加本地用户

    这里写图片描述

    3、配置私服(settings.xml)

    <!--设置的maven本地仓库-->
    <localRepository>D:installmaven
    epository</localRepository>
    
    <servers>
        <server>
        <!--这是server的id(注意不是用户登陆的id),该id与distributionManagement中repository元素的id相匹配。 -->
          <id>nexus</id>
          <username>admin</username>
          <password>admin123</password>
         </server>
    </servers>
    
    <!--为仓库列表配置的下载镜像列表。  -->
    <mirrors>
        <mirror>
            <!--该镜像的唯一标识符。id用来区分不同的mirror元素。  -->
            <id>nexus</id>
            <!--此处配置所有的构建均从私有仓库中下载 *代表所有,也可以写central -->
            <mirrorOf>*</mirrorOf>
            <name>central repository</name>
            <!--该镜像的URL。构建系统会优先考虑使用该URL,而非使用默认的服务器URL。  -->
            <url>http://192.168.10.68:8081/repository/maven-public/</url>
        </mirror>
    </mirrors>
    
    <profiles>
      <profile>
          <id>nexus</id>
          <!--远程仓库列表,它是Maven用来填充构建系统本地仓库所使用的一组远程项目。  -->
          <repositories>
              <!--发布版本仓库-->
              <repository>
                  <id>nexus</id>      
                  <!--地址是nexus中repository(Releases/Snapshots)中对应的地址-->
                  <url>http://192.168.10.68:8081/repository/maven-public/</url>
              <!--true或者false表示该仓库是否为下载某种类型构件(发布版,快照版)开启。 -->
              <releases>
                  <enabled>true</enabled>
              </releases>
              <snapshots>
                  <enabled>true</enabled>
              </snapshots>
          </repository>
          </repositories>
      </profile>     
    </profiles>
    
    <!--激活配置-->
    <activeProfiles>
        <!--profile下的id-->
        <activeProfile>nexus</activeProfile>
    </activeProfiles>

    4、上传jar包到Nexus

    • 4.1、直接上传jar(在cmd中输入下列命令:)
    mvn deploy:deploy-file -DgroupId=xxx.xxx -DartifactId=xxx -Dversion=xxx -Dpackaging=jar -Dfile=D:xxx.jar -Durl=http://xxx.xxx.xxx.xxx:8081/repository/maven-releases/ -DrepositoryId=nexus
    • 1

    注释:

    -DgroupId 为上传的jar的groupId
    
    -DartifactId 为上传的jar的artifactId
    
    -Dversion 为上传的jar的需要被依赖的时候的版本号
    
    -Dpackaging为jar
    
    -Dfile为jar包路径 
    
    -Durl 为要上传的路径,-DrepositoryId 为repository的唯一标示,跟第3步中赋权配置的server相同
    
    注意:-Dfile中的路径最好就在D盘的根目录D:xxx.jar,不要D:xxxxxxxxxxxx.jar,这样可能会报错
    • 4.2、直接将项目发布到仓库中

    pom.xml中添加,和dependencies属于同一级别,在project级别下

    <distributionManagement>  
         <repository>  
             <id>nexus</id>  
             <name>releases Repository</name>  
             <url>http://192.168.10.68:8081/repository/maven-releases/</url>  
         </repository>  
    </distributionManagement> 

    添加完后,cd到pom.xml文件目录中运行:mvn deploy即可

    注:id为要上传的repository的唯一标示,url为要上传的repository的路径

    • 4.3、示例(第一种方法)

    运行:

    mvn deploy:deploy-file -DgroupId=org.olap4j -DartifactId=olap4j -Dversion=0.9.7.309-JS-3 -Dpackaging=jar -Dfile=D:olap4j-0.9.7.309-JS-3.jar -Durl=http://192.168.10.68:8081/repository/maven-releases/ -DrepositoryId=nexus
    • 1

    查看仓库结果:

    这里写图片描述

  • 相关阅读:
    战略威慑 51nod提高组试题
    赛艇表演 51nod提高组模拟试题
    Emiya家今天的饭 NOIP2019 (CSP?) 类DP好题 luoguP5664
    华容道题解 NOIP2013 思路题!
    (板子) 最小生成树 买礼物 luogu P1194
    (板子)并查集(递归+循环)
    校园网络 luogu P2812 (又是强联通)
    货车运输 noip2013 luogu P1967 (最大生成树+倍增LCA)
    Codeforces Round #684 (Div. 2)
    Codeforces Round #683 (Div. 2, by Meet IT)
  • 原文地址:https://www.cnblogs.com/a-du/p/9648449.html
Copyright © 2011-2022 走看看