Nexus3.6 window版私服搭建 安装、配置教程

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


  • 1.1、官网下载地址:https://www.sonatype.com/download-oss-sonatype
                 百度网盘地址:https://pan.baidu.com/s/1hr4yG0c
  • Nexus3.6 window版私服搭建 安装、配置教程_第1张图片

  • 1.2、解压得到目录
  • Nexus3.6 window版私服搭建 安装、配置教程_第2张图片

  • 1.3、将Nexus的bin目录添加到Path环境变量中:
  • Nexus3.6 window版私服搭建 安装、配置教程_第3张图片

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

  • 1.5、访问浏览器(http://localhost:8081)
    到此配置完毕,然后,即可在本地访问Nexus,如出现下图就表示配置成功:
  • Nexus3.6 window版私服搭建 安装、配置教程_第4张图片

    Nexus3.6 window版私服搭建 安装、配置教程_第5张图片

    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、增加仓库(以增加宿主仓库为例)
  • Nexus3.6 window版私服搭建 安装、配置教程_第6张图片

    Nexus3.6 window版私服搭建 安装、配置教程_第7张图片

  • 2.4、增加本地用户
  • Nexus3.6 window版私服搭建 安装、配置教程_第8张图片

    3、配置私服(settings.xml)

    
    <localRepository>D:\install\maven\repositorylocalRepository>
    
    <servers>
        <server>
        
          <id>nexusid>
          <username>adminusername>
          <password>admin123password>
         server>
    servers>
    
    
    <mirrors>
        <mirror>
            
            <id>nexusid>
            
            <mirrorOf>*mirrorOf>
            <name>central repositoryname>
            
            <url>http://192.168.10.68:8081/repository/maven-public/url>
        mirror>
    mirrors>
    
    <profiles>
      <profile>
          <id>nexusid>
          
          <repositories>
              
              <repository>
                  <id>nexusid>      
                  
                  <url>http://192.168.10.68:8081/repository/maven-public/url>
              
              <releases>
                  <enabled>trueenabled>
              releases>
              <snapshots>
                  <enabled>trueenabled>
              snapshots>
          repository>
          repositories>
      profile>     
    profiles>
    
    
    <activeProfiles>
        
        <activeProfile>nexusactiveProfile>
    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

    注释:

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

  • 4.2、直接将项目发布到仓库中
  • pom.xml中添加,和dependencies属于同一级别,在project级别下

    <distributionManagement>  
         <repository>  
             <id>nexusid>  
             <name>releases Repositoryname>  
             <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

    查看仓库结果:

    Nexus3.6 window版私服搭建 安装、配置教程_第9张图片

    你可能感兴趣的:(utils)