zoukankan      html  css  js  c++  java
  • nexus

    搭建nexus

    下载,解压,安装

    nexus-2.12.0-01-bundle.zip 解压,进入 bin 目录,命令提示符 执行命令 nexus install 。卸载的命令为 nexus uninstall 。

    启动

    在电脑的的服务中,找到 nexus 右击启动。

    进入

    浏览器输入地址:http://localhost:8081/nexus 。点击右上角的Log In,在弹出窗口中输入 username 为 admin,password 为 admin123 。

    构建索引

    刚刚安装好的 nexus 是无法直接搜索到 jar 包的,必须下载索引才可以正常使用。

    我们到中央仓库地址 http://repo.maven.apache.org/maven2/.index/ 下载以下两个索引压缩文件
    nexus-maven-repository-index.gz
    nexus-maven-repository-index.properties
    这两个文件一般在此页面的最后的位置,另外还需要在网上下载一个名为 indexer-cli-5.1.1.jar 的 jar 包。

    将以下三个文件放入一个文件夹中,DOS 进入文件夹,执行命令 java -jar indexer-cli-5.1.1.jar -u nexus-maven-repository-index.gz -d indexer
    执行后生成目录indexer,目录下的文件是索引文件。

    把 nexus-2.12.0-01-bundlesonatype-work exusindexercentral-ctx 目录下的文件删除,将上边的索引文件拷贝到此目录下。
    拷贝后重新启动 nexus,然后进入 nexus 搜索 jar 包发现可以进行搜索了。

    仓库类型

    1、hosted:宿主仓库,自己项目的 jar 要放到 hosted 类型的仓库中。
    2、proxy:代理仓库,代理中央仓库。也可以配置其他地址的代理,如aliyun 等。
    3、virtual:虚拟仓库,存储了 maven1 的构件,一般不用。
    4、group:仓库组,将一些仓库组成一个组,自己项目连接仓库组去下载 jar 包。

    平常开发中都去连接仓库组,仓库组中包括:hosted、proxy 等。

    镜像配置

    nexus 安装好后,的使用。需要在 maven 的配置文件 settings.xml 中配置镜像,让 maven 找私服,而不是直接到中央仓库下载。
    打开 maven 的配置文件 settings.xml,添加如下配置:

    <mirrors>
        <mirror>
          <id>nexus</id>
          <mirrorOf>*</mirrorOf>
          <url>http://localhost:8081/nexus/content/groups/public/</url>
        </mirror>
    </mirrors>

    mirrors 为镜像组,可以配置多个 mirror,我们这里配置的是 nexus 中的中央代理仓库。

    发布自己的工程 jar 到 nexus

    在 工程的 pom 中添加以下配置

    <distributionManagement>
          <repository>
              <id>releases</id>
            <url>
                 http://localhost:8081/nexus/content/repositories/releases/
           </url>
          </repository> 
          <snapshotRepository>
              <id>snapshots</id>    
            <url>
                http://localhost:8081/nexus/content/repositories/snapshots/
            </url>
          </snapshotRepository> 
      </distributionManagement>

    在 maven 的 settings.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>

    注意:settings.xml 配置 <id>和 pom.xml<id> 对应!
    然后执行命令 mvn deploy 。

    发布第三方的工程 jar 到 nexus

    有很多 jar 包由于版权等问题,并不会出现在中央仓库中,比如 oracle 的驱动,那如何将这类 jar 包放在 nexus 中呢?我们看下列操作步骤:

    (1)选择左侧菜单的Repositories,  在Repositories窗口中选择3rd party

    (2)在3rd party 窗口中选择 Artifact Upload

    (3)在 Artifact Upload 选项卡中填写坐标,并上传 jar 包。

    上传 jar 包选择 oracle 的驱动。

    填写坐标

    有下列提示则为上传成功

    上传成功后可以在 3rd party 库中找到此 jar 包

  • 相关阅读:
    linux_grep操作
    linux_awk操作
    linux_sed操作
    [题解]USACO 5.2.1 Snail Trails
    [数据生成器]UVA10054 The Necklace
    [题解]UVA10054 The Necklace
    [题解]UVA11027 Palindromic Permutation
    [题解]UVA10129 Play on Words
    [题解]UVA11029 Leading and Trailing
    计蒜客NOIP2017提高组模拟赛(五)day1-机智的 AmyZhi
  • 原文地址:https://www.cnblogs.com/boomoom/p/10661356.html
Copyright © 2011-2022 走看看