zoukankan      html  css  js  c++  java
  • nexus安装及使用(maven私服掌握)

    本文链接:https://blog.csdn.net/qq_33248299/article/details/83386184

    一.Nexus安装

    1.Nexus介绍

    • 是种特殊的Maven仓库一般用于公司
      在这里插入图片描述

    2.Nexus安装

    https://www.sonatype.com/oss-thank-you-win64.zip 下载并解压如下

    在这里插入图片描述

    • 执行命令安装私服(使用管理员权限在dos下执行命令安装私服)
    nexus.exe /install //安装
    nexus.exe /uninstall//卸载
    net start nexus //启动
    net stop nexus//停止

    3.配置Nexus

    在etc目录下的nexus-default.properties配置Nexus端口、IP、上下文路径
    在这里插入图片描述

    在这里插入图片描述

    • application-host : Nexus服务监听的主机
    • application-port: Nexus服务监听的端口
    • nexus-context-path : Nexus服务的上下文路径

    4.启动服务

    5.找到私服的url

    http://localhost:8081/nexus/#welcome
    

    登录

    默认用户 密码
    admin/admin123
    

    二.私服仓库类型

    在这里插入图片描述

    • hosted:宿主仓库(存放本公司开发的jar包(正式版本 测试版本 第三方:存在版权问题的-Oracle))
    • proxy:代理仓库(代理中央仓库,apache下测试版本的jar包)
    • group:组仓库(将来连接组仓库。包含Hosted:宿主仓库,proxy:代理仓库)
    • virtual:虚拟仓库(被废弃了的仓库)

    三.上传jar包到私服

    1.在maven目录下conf/setting.xml认证:配置用户名和密码

    <servers>
     <server>
          <id>releases</id> <!--宿主仓库-->
          <username>admin</username>
          <password>admin123</password>
        </server>
        <server>
              <id>snapshots</id><!--宿主仓库-->
              <username>admin</username>
              <password>admin123</password>
        </server>
    
        </servers>
    

    2.在将要上传的项目的pom.xml中配置jar包上传路径url

    • 我们上传ssh-dao
      在这里插入图片描述
    <distributionManagement>
      <repository>
          <id>releases</id>
          <url>http://localhost:8081/nexus/repository/maven-releases</url><!--私服对应url-->
        </repository>
        <snapshotRepository>
          <id>snapshots</id>
          <url>http://localhost:8081/nexus/repository/maven-snapshots</url><!--私服对应url-->
        </snapshotRepository>
      </distributionManagement>
    

    3.执行命令发布项目到私服(上传)-执行deploy

    在这里插入图片描述

    在这里插入图片描述
    四.从私服上下载jar包到本地仓库

    1.在maven目录下conf/setting.xml配置模板

        <profile>
            	<!--profile的id-->
          <id>dev</id>
          <repositories>
            <repository>
            	<!--仓库id,repositories可以配置多个仓库,保证id不重复-->
              <id>nexus</id>
              <!--仓库地址,即nexus仓库组的地址-->
              <url>http://localhost:8081/nexus/repository/maven-public</url>
              <!--是否下载releases构件-->
              <releases><enabled>true</enabled></releases>
               <!--是否下载snapshots构件-->
              <snapshots><enabled>true</enabled></snapshots>
            </repository>
          </repositories>
         <pluginRepositories>
         	<!--插件仓库,maven的运行依赖插件,也需要从私服下载插件-->
            <pluginRepository>
            	<!--插件仓库的id不允许重复,如果重复后边配置会覆盖前边-->
              <id>public</id>
              <name>Public Repositories</name>
              <url>http://localhost:8081/nexus/repository/maven-public</url>
            </pluginRepository>
          </pluginRepositories>
        </profile>
    

    2.激活模板(也是放在maven下的setting.xml中)

    <activeProfiles>
            <activeProfile>dev</activeProfile>
    </activeProfiles>
    

    3.测试下载

    • 我们先去把本地仓库的对应项目jar包整体删掉
    • 发现项目还没有报错,因为现在每个项目都打开,所以依赖的是项目,而不是jar包
    • 关掉ssh-dao项目,报错 之后就去私服上下载了,之后查看本地仓库又存在了对应的包
      在这里插入图片描述

    在这里插入图片描述

    Maven私服搭建(nexus)

  • 相关阅读:
    python RabbitMQ
    python IO多路复用版FTP
    python SelectPollEpoll异步IO与事件驱动
    python 同步与异步的性能区别及实例
    mysql学习笔记1---mysql ERROR 1045 (28000): 错误解决办法(续:深入分析)
    mysql学习笔记1---mysql ERROR 1045 (28000): 错误解决办法
    Ubuntu 安装HBase
    微博excel数据清洗(Java版)
    hadoop之mapreduce编程实例(系统日志初步清洗过滤处理)
    MapReduce编程实例6
  • 原文地址:https://www.cnblogs.com/But-you/p/11584150.html
Copyright © 2011-2022 走看看