天天看点

Nexus私服搭建_01

nexus私服安装

第一步:下载nexus-webapp-2.9.0war包,然后拷贝到tomcat下的webapps目录中

第二步:启动tomcat

Nexus私服搭建_01

第四步:点击右上角“log in” ,输入username:admin 和password:admin123登录

Nexus私服搭建_01

第五步:登录成功

Nexus私服搭建_01

第六步:点击views/repositories 中repositories

Nexus私服搭建_01

nexus内置仓库说明:

(1)maven central:该仓库代理maven中央仓库,其策略为release,因此只会下载和缓存中央仓库中的发布版本构件。

(2)releases:这是一种策略为release的宿主类型仓库,用来部署组织内部的发布版本构件。

(3)snapshots:这是一个策略为snapshot的宿主类型仓库,用来部署组织内部的快照版本构件。

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

(5)public repositories:该仓库组将上述所有策略为release的仓库聚合并通过一致的地址提供服务。

第七步:创建宿主目录和代理仓库

· hosted:本地仓库,通常我们会部署自己的构件到这一类型的仓库。 

o 包括3rd party仓库,releases仓库,snapshots仓库

· proxy:代理仓库,它们被用来代理远程的公共仓库,如maven中央仓库。 

· group:仓库组,用来合并多个hosted/proxy仓库,通常我们配置maven依赖仓库组。 

第八步:创建仓库组

点击public repositories仓库,在configurations栏中选取需要合并的仓库,点击箭头加到左边保存即可

Nexus私服搭建_01

第九步:下载index索引并进行构建搜索(gav搜索)

配置文件和顺序:maven_home/conf/setting.xml-à~/.m2/setting.xml-àproject

第十步:配置所有构件均从私服下载,在~/.m2/setting.xml中配置如下:

Nexus私服搭建_01

<settings xmlns="http://maven.apache.org/settings/1.0.0"  

          xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"  

          xsi:schemalocation="http://maven.apache.org/settings/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">  

  <mirrors>  

    <mirror>  

    <!--此处配置所有的构建均从私有仓库中下载 *代表所有,也可以写central -->  

      <id>nexus</id>  

      <mirrorof>*</mirrorof>  

      <name>central repo</name>  

      <url>http://localhost:8089/nexus-2.9.0/content/groups/public/</url>  

    </mirror>  

  </mirrors>  

  <profiles>  

    <profile>  

        <id>nexus</id>  

        <repositories>  

            <repository>  

                <id>central</id>  

                <name>central</name>  

                <url>http://repo2.maven.org/maven2</url>  

                <releases><enabled>true</enabled></releases>  

                <snapshots><enabled>true</enabled></snapshots>  

            </repository>  

        </repositories>  

        <pluginrepositories>  

            <pluginrepository>  

            </pluginrepository>  

        </pluginrepositories>  

    </profile>  

  </profiles>  

  <activeprofiles>  

    <activeprofile>nexus</activeprofile>  

  </activeprofiles>  

</settings>  

第十一步:部署构建到nexus,包含release和snapshot, 在项目根目录中pom.xml中配置:

Nexus私服搭建_01

<span style="font-family:microsoft yahei;font-size:12px;"><distributionmanagement>  

        <repository>  

            <id>releases</id>  

            <name>internal releases</name>  

            <url>http://localhost:8080/nexus-2.9.0/content/repositories/releases/</url>  

        </repository>  

        <snapshotrepository>  

            <id>snapshots</id>  

            <name>internal snapshots</name>  

            <url>http://localhost:8080/nexus-2.9.0/content/repositories/snapshots/</url>  

        </snapshotrepository>  

    </distributionmanagement></span>  

第十二步:nexus的访问权限控制,在~/m2/setting.xml中配置如下:

<!-- 设置发布时的用户名 -->

Nexus私服搭建_01

<span style="font-family:microsoft yahei;font-size:12px;"><servers>  

    <server>  

        <id>releases</id>  

        <username>admin</username>  

        <password>admin123</password>  

    </server>  

        <id>snapshots</id>  

  </servers></span>