PW Nexus configuration (rpm)

https://www.cnblogs.com/yuanermen/p/4574473.html

I. Overview

    1, Overview

     The project is now basically use Maven to manage the project, so that the company set up a PW content is very necessary, and this way you can manage internal company use the JAR package, you can also manage third-party JAR to, every time so as not to be downloaded from the external network of warehouses. PW has two software built Nexus and artifactory, both have their advantages. artifactory  three years ago after a configuration, this configuration at Nexus. Nexus is a relatively popular PW.

    2, Nexus introduction

       Nexus is a powerful Maven repository manager, which greatly simplifies maintenance and access to external warehouse of their own internal warehouse. You can only use Nexus in one place will be able to completely control access and deployment in your warehouse maintained by each of the Artifact. Nexus is a set of "out of the box" system does not require a database, it uses the file system to organize the data Lucene added. Nexus using ExtJS to develop interfaces to provide a complete REST APIs, through the use of integrated Eclipse m2eclipse and use Restlet. Nexus supports WebDAV and LDAP authentication security.

  Download Nexus is: http: //www.sonatype.org/nexus/go/ to the official website to download ZIP compressed package down to, after extracting found two folders, one is the nexus-2.11.0- 02, and the other is sonatype-work; the first folder contains the files needed to run the Nexus, Nexus is necessary to run; the second folder directory contains the Nexus generated configuration files, log files, repository files, when the time required to back up the Nexus, this directory is the default backup file.

Second, prepare the environment

    1, Maven 3.3.3  download the latest version 3 \

    2, Nexus 2.11.1-01-bundle download the latest version of the current

Three, Nexus Installation and Configuration

   1, Nexus installation

      After downloading the nexus, only need to unpack the archive file after extracting the folder into the directory you want to install - I was the D drive.

   2, configure the Nexus environment variables

      The nexus of the bin directory to environment variable path in the (relatively simple not explained in detail)

   3. Configure Nexus

     In the root of the nexus of bin \ jsw \ conf \ wrapper.conf files found

     # Set the JVM executable should be about 15 lines, the path to the configuration JAVA

     wrapper.java.command=D:\Program Files\Java\jdk1.7.0_71\bin\java

     The path java.exe under the java directory configuration to which you can (depending on your computer's configuration java)

    4, Nexus test

      Open a command line with administrator privileges (if your user is not the Administrator will remind: Error OpenSCManager failed access denied)

     If the input nexus following tips which proved successful configuration --nexus environment variable configuration from the command line success

    5, Nexus install and start

        Enter the nexus start following information: Description nexus configured, but not yet installed

     Input nexus install to install - the following information that is successfully installed

       Start nexus: Enter the nexus start to

     6, failed to start

        If it failed to start prompt:

        wrapper | The nexus service was launched, but failed to start

       There are two possible reasons:

       1, Nexus installation directory bin \ jsw \ conf \ wrapper.conf the java configuration error cause failed to start (the possibility of error 1: Wrong version; possibility of error 2: the wrong path).

       2,8081 port is occupied cause fails to start (if non-system process takes, the end of the process can be), or modify the port Jetty to find application-port = 8081 in the Nexus installation currently /conf/nexus.properties file instead 8181 on the line.

    7, success

        Default address: http: //127.0.0.1: 8081 / nexus

        Top right, click Log In to log in, the default account: admin, password: admin123

Four, Nexus initial configuration

     1, Nexus overall presentation

             We can see from the image above four kinds of warehouse types: group (warehouse group), hosted (host), proxy (proxy) and virtual (virtual). Format in which each type have Maven1 or Maven2, here we do not see the Maven1. Warehouse Policy (Policy) indicates that the warehouse is released (Release) version or snapshot (Snapshot) version of the warehouse.

    In the figure, Nexus lists the default of several warehouses:

    Public Repositories: warehouse group, all policies to Release polymerization warehouses and provide services through the same address.

    3rd party: a strategy for the Release of the host type warehouse, used to deploy third-party publishers release member can not be obtained from a public warehouse.

    Apache Snapshots: Snapshots of policy for the warehouse agent, the agent for snapshot version of the component Apache Maven repository.

    Central: The central warehouse warehouse agent Maven, strategies for the Release, only download and cache the central warehouse releases members.

    Central M1 shadow: a virtual warehouse maven1 type format.

    Codehaus Snapshots: Snapshot Agent Codehaus Maven repository version of the warehouse agent.

    Release:策略为Release的宿主类型仓库,用来部署组织内部的发布版本构件。

    Snapshots:策略为Snapshots的宿主类型仓库,用来部署组织内部的快照版本构件。

     2、点击左侧Repositories项 -> central仓库 -> Configuration -> Download Remote Indexes=True -> Save,表示下载远程仓库的索引。

        同时override local storage location 也是可以改一下。

        点击“save”。

       点击左边的“Administration”->"Scheduled Tasks"链接,如果没有出现“Update Repositories Index”处于Running状态,那么需要在Public Repositories行右击,点击"Update Index"。

       然后再点击Schedule Tasks就可以看到有任务处于Running状态了。

      等到索引下载完成之后,就可以在"Repositories"界面中,选择Browser Index选项卡,可以看到Maven中央仓库内容的树形结构.

    3、手动上传JAR包

               GAV Definition:选择GAV Parameters

               输入JAR包对应的:Group\Artifact\verison\

               选择JAR

              第三步上传包,第四步add artifact 最后update artifact.

              这样包上传成功。POM可以用了。

     4、Maven的配置

          在Maven安装目录conf/setting.xml 在<mirrors>内配置如下内容

<mirror>  
        <id>nexus</id>  
        <name>internal nexus repository</name>  
        <url>http://127.0.0.1:8081/nexus/content/groups/public/</url>  
        <mirrorOf>*</mirrorOf>  
</mirror>  

         在执行

mvn clean eclipse:eclipse -Ddowloadsources=true

       下自动从Nexus私服中下载JAR包。

     5、部署构件到私服

  我们在实际开发过程是多个人的,那么总有一些公共模块或者说第三方构件是无法从Maven中央库下载的。我们需要将这些构件部署到私服上,供其他开发人员下载。用户除了通过界面手动上传构件,也可以配置Maven自动部署构件至Nexus的宿主仓库。

使用Maven部署构件到Nexus私服上日常开发的快照版本部署到Nexus中策略为Snapshot的宿主仓库中,正式项目部署到策略为Release的宿主仓库中,POM的配置方式如下:

复制代码
 <!-- 配置远程发布到私服,mvn deploy -->   
 <distributionManagement>   
        <repository>   
            <id>releases</id>   
            <name> Nexus Release Repository </name>   
            <url> http://127.0.0.1:8081/nexus/content/repositories/releases/ </url>   
        </repository>   
        <snapshotRepository>   
            <id>snapshots</id>   
            <name> Nexus Snapshot Repository </name>   
            <url> http://127.0.0.1:8081/nexus/content/repositories/snapshots/ </url>   
        </snapshotRepository >   
  </distributionManagement >  
复制代码

Nexus的仓库对于匿名用户只是只读的。为了能够部署构件,我们还需要再settings.xml中配置验证信息:

复制代码
server>  
        <id>snapshots</id>  
        <username>admin</username>  
        <password>admin123</password>  
</server>
<server>   
    <id>releases</id>   
    <username>admin</username>   
    <password>admin123</password>   
</server>   
复制代码

其中,验证信息中service的id应该与POM中repository的id一致。

这样通过 maven 可以自动布置到Nexus私服中了。命令如下:

mvn clean deploy -Dmaven.test.skip=true

 这样就可以把把自动的发布到nexus中去了。

     6、完工

 

一、概述

    1、概要

     现在的项目基本都是用Maven来管理工程,这样一来在公司内容搭建一个私服就非常有必要了,这样一来可以管理公司内部用的JAR包,也可以管理第三方的各种JAR来,以免每次都要从外网的仓库中下载。私服有两种软件搭建Nexus和artifactory,这两个各有优点。artifactory 三年前已配置过了,本文配置一下Nexus。Nexus还是一个比较流行的私服。

    2、Nexus介绍

       Nexus是一个强大的Maven仓库管理器,它极大地简化了自己内部仓库的维护和外部仓库的访问。利用Nexus你可以只在一个地方就能够完全控制访问 和部署在你所维护仓库中的每个Artifact。Nexus是一套“开箱即用”的系统不需要数据库,它使用文件系统加Lucene来组织数据。Nexus 使用ExtJS来开发界面,利用Restlet来提供完整的REST APIs,通过m2eclipse与Eclipse集成使用。Nexus支持WebDAV与LDAP安全身份认证。

  Nexus的下载地址是:http://www.sonatype.org/nexus/go/到官网上将ZIP的压缩包下载下来即可,解压之后发现有两个文件夹,一个是nexus-2.11.0-02,另一个是sonatype-work;第一个文件夹包含了Nexus运行所需要的文件,是运行Nexus必须的;第二个文件夹目录包含Nexus生成的配置文件、日志文件、仓库文件等,当需要备份Nexus的时候,默认备份的是此目录文件。

二、环境准备

    1、maven 3.3.3 下载最新的版本3\

    2、Nexus 2.11.1-01-bundle下载当前最新的版本

三、Nexus的安装配置

   1、Nexus安装

      下载完nexus之后,只需要将压缩包解压,将解压后的文件夹放到你想要安装的目录即可——我的为D盘。

   2、配置Nexus环境变量

      将nexus的bin目录设置到path的环境变量中(比较简单不详细讲解了)

   3、配置Nexus

     在 nexus的根目录bin\jsw\conf\wrapper.conf的文件在找到

     # Set the JVM executable应该在15行左右,配置JAVA的路径

     wrapper.java.command=D:\Program Files\Java\jdk1.7.0_71\bin\java

     将java目录下的java.exe的路径配置到里面即可(根据你电脑java的配置)

    4、Nexus的测试

      用管理员权限打开命令行(如果你的用户不是Administrator则会提醒:出现 OpenSCManager failed 拒绝访问的错误)

     在命令行中输入nexus如果出现下面提示这证明配置成功——nexus的环境变量配置成功

    5、Nexus安装并启动

        输入nexus start出现如下信息:说明nexus配置好了,但是还没有安装

     输入nexus install即可安装——如下信息即安装成功

       启动nexus:输入nexus start即可

     6、启动失败

        如果启动失败提示:

        wrapper | The nexus service was launched, but failed to start

       可能有两种原因:

       1、Nexus安装目录 bin\jsw\conf\wrapper.conf中的java配置错误导致启动失败(错误可能性1:版本错误;错误可能性2:写错路径了).

       2、8081端口被占用导致启动失败(如果是非系统进程占用,结束该进程即可),或修改Jetty的端口,在Nexus的安装目前/conf/nexus.properties文件中找到 application-port=8081 改为8181就行了。

    7、成功

        默认地址:http://127.0.0.1:8081/nexus

        点击右上角Log In进行登录,默认帐号:admin、密码:admin123

四、Nexus初始化配置

     1、Nexus整体介绍

             我们可以从上图中看到四种仓库类型:group(仓库组)、hosted(宿主)、proxy(代理)和virtual(虚拟)。其中每种类型的Format有Maven1或者Maven2,这里我们不看Maven1的。仓库的Policy(策略)表示该仓库为发布(Release)版本还是快照(Snapshot)版本仓库。

    在图中,Nexus列出了默认的几个仓库:

    Public Repositories:仓库组,将所有策略为Release的仓库聚合并通过一致的地址提供服务。

    3rd party:一个策略为Release的宿主类型仓库,用来部署无法从公共仓库获得的第三方发布版本构件。

    Apache Snapshots:策略为Snapshots的代理仓库,用来代理Apache Maven仓库的快照版本构件。

    Central:该仓库代理Maven的中央仓库,策略为Release,只会下载和缓存中央仓库中的发布版本构件。

    Central M1 shadow:maven1格式的虚拟类型仓库。

    Codehaus Snapshots:代理Codehaus Maven仓库快照版本的代理仓库。

    Release:策略为Release的宿主类型仓库,用来部署组织内部的发布版本构件。

    Snapshots:策略为Snapshots的宿主类型仓库,用来部署组织内部的快照版本构件。

     2、点击左侧Repositories项 -> central仓库 -> Configuration -> Download Remote Indexes=True -> Save,表示下载远程仓库的索引。

        同时override local storage location 也是可以改一下。

        点击“save”。

       点击左边的“Administration”->"Scheduled Tasks"链接,如果没有出现“Update Repositories Index”处于Running状态,那么需要在Public Repositories行右击,点击"Update Index"。

       然后再点击Schedule Tasks就可以看到有任务处于Running状态了。

      等到索引下载完成之后,就可以在"Repositories"界面中,选择Browser Index选项卡,可以看到Maven中央仓库内容的树形结构.

    3、手动上传JAR包

               GAV Definition:选择GAV Parameters

               输入JAR包对应的:Group\Artifact\verison\

               选择JAR

              第三步上传包,第四步add artifact 最后update artifact.

              这样包上传成功。POM可以用了。

     4、Maven的配置

          在Maven安装目录conf/setting.xml 在<mirrors>内配置如下内容

<mirror>  
        <id>nexus</id>  
        <name>internal nexus repository</name>  
        <url>http://127.0.0.1:8081/nexus/content/groups/public/</url>  
        <mirrorOf>*</mirrorOf>  
</mirror>  

         在执行

mvn clean eclipse:eclipse -Ddowloadsources=true

       下自动从Nexus私服中下载JAR包。

     5、部署构件到私服

  我们在实际开发过程是多个人的,那么总有一些公共模块或者说第三方构件是无法从Maven中央库下载的。我们需要将这些构件部署到私服上,供其他开发人员下载。用户除了通过界面手动上传构件,也可以配置Maven自动部署构件至Nexus的宿主仓库。

使用Maven部署构件到Nexus私服上日常开发的快照版本部署到Nexus中策略为Snapshot的宿主仓库中,正式项目部署到策略为Release的宿主仓库中,POM的配置方式如下:

复制代码
 <!-- 配置远程发布到私服,mvn deploy -->   
 <distributionManagement>   
        <repository>   
            <id>releases</id>   
            <name> Nexus Release Repository </name>   
            <url> http://127.0.0.1:8081/nexus/content/repositories/releases/ </url>   
        </repository>   
        <snapshotRepository>   
            <id>snapshots</id>   
            <name> Nexus Snapshot Repository </name>   
            <url> http://127.0.0.1:8081/nexus/content/repositories/snapshots/ </url>   
        </snapshotRepository >   
  </distributionManagement >  
复制代码

Nexus的仓库对于匿名用户只是只读的。为了能够部署构件,我们还需要再settings.xml中配置验证信息:

复制代码
server>  
        <id>snapshots</id>  
        <username>admin</username>  
        <password>admin123</password>  
</server>
<server>   
    <id>releases</id>   
    <username>admin</username>   
    <password>admin123</password>   
</server>   
复制代码

其中,验证信息中service的id应该与POM中repository的id一致。

这样通过 maven 可以自动布置到Nexus私服中了。命令如下:

mvn clean deploy -Dmaven.test.skip=true

 这样就可以把把自动的发布到nexus中去了。

     6、完工

 

Guess you like

Origin www.cnblogs.com/guanbin-529/p/10994698.html