Nexus安装及部署(含如何在Tomcat中部署)

1、 Nexus价值
  1)方便-节约带宽-快
  2)便于统一管理
  3)持续集成需要

2、Nexus下载

  http://www.sonatype.org/nexus/go

3、Nexus启动

  解压后进入\nexus-2.14.2-01-bundle\nexus-2.14.2-01\bin\jsw\,根据操作系统类型选择文件夹,如果是Windows则选择windows-x**-**文件夹,双击console-nexus.bat运行。然后在浏览器中输入
http://127.0.0.1:8081/nexus/即可访问。可进入nexus-2.14.2-01-bundle\nexus-2.14.2-01\conf\打开nexus.properties文件,修改相关属性。nexus默认的用户名和密码为:admin/admin123。


4、如何通过tomcat部署
  nexus默认是和jetty集成的,如果您使用的是tomcat环境,则按照如下步骤进行配置即可:
  4.1)创建目录如“F:\tomcatweb\nexus”(用于存放您的nexus),将解压后的nexus包中的nexus-2.14.2-01 和 sonatype-work两个文件夹拷贝到nexus目录中
  4.2)进入\nexus\nexus-2.14.2-01\lib目录,将非jetty的所有jar文件拷贝到\nexus\nexus-2.14.2-01\nexus\WEB-INF\lib中
  4.3)进入\nexus\nexus-2.14.2-01\nexus\WEB-INF\classes,修改nexus.properties文件:nexus-work=F:/tomcatweb/nexus/sonatype-work/nexus
  4.4)修改tomcat中conf/server.xml文件:

       <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
		<Context docBase="F:\tomcatWeb\nexus\nexus-2.14.2-01\nexus" path="/nexus" reloadable="true"/>
	</Host>

  4.5)启动tomcat
  使用网址进入:http://localhost:8080/nexus,注意修改用户名密码

5、Nexus仓库
  nexus的仓库类型分为以下四种:
    group: 仓库组
    hosted:宿主
    proxy:代理
    virtual:虚拟
  首次登陆nexus后可以看到以下一个仓库组和多个仓库:
    Public Repositories: 仓库组(项目中如果要下载构件的话,配置文件中一般都用仓库组的URL)
    3rd party: 无法从公共仓库获得的第三方发布版本的构件仓库(如oracle驱动)
    Apache Snapshots: 用了代理ApacheMaven仓库快照版本的构件仓库(别忘了更新索引
    Central: 用来代理maven中央仓库中发布版本构件的仓库(别忘了更新索引
    Central M1 shadow: 用于提供中央仓库中M1格式的发布版本的构件镜像仓库(一般不用管)
    Releases: 用来部署您公司的发布版本构件的宿主类型仓库(重要)
    Snapshots:用来部署您公司的快照版本构件的宿主类型仓库(重要)

  您也可以添加仓库组或者代理仓库(如阿里云maven仓库),其他的看情况吧。

6、修改本地的maven配置文件
  6.1)进入目录并打开文件:maven\conf\setting.xml(进入eclipse->windows->Perference->maven->installations中查看您用的是哪个maven)
  6.2)修改:<localRepository>F:\JavaMavenRepo</localRepository>
  6.3)配置仓库:

<profiles>    
    <profile>    
      <id>companyRep</id>    
      <repositories>    
            <repository>    
                <id>central</id>                                       
                <url>http://localhost:8080/nexus/content/groups/public/</url>         
                <releases>    
                    <enabled>true</enabled>    
                </releases>    
                <snapshots>    
                    <enabled>true</enabled>    
                </snapshots>    
            </repository>    
        </repositories>       
         <pluginRepositories>    
            <pluginRepository>    
              <id>central</id>    
              <url>http://localhost:8080/nexus/content/groups/public/</url>
              <releases>    
                <enabled>true</enabled>    
              </releases>    
              <snapshots>    
                <enabled>false</enabled>    
              </snapshots>    
            </pluginRepository>    
        </pluginRepositories>    
    </profile>    
</profiles> 

6.4)激活profile

<activeProfiles>    
    <activeProfile>companyRep</activeProfile>    
</activeProfiles>  

6.5)配置镜像

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

  这里配置mirrorOf的值为*,代表maven的所有访问请求都会指向到Nexus仓库组。
6.6)添加认证信息

<servers>    
     <server>    
      <id>commanyRep-releases</id>    
      <username>admin</username>    
      <password>admin123</password>    
    </server>    
    <server>    
      <id>commanyRep-snapshot</id>    
      <username>admin</username>    
      <password>admin123</password>    
    </server>    
</servers> 

7、自动部署构件到Nexus仓库
  7.1) 修改pom文件(自动部署)

<distributionManagement>    
       <repository>    
           <id>commanyRep-releases</id>    
           <url>http://localhost:8080/nexus/content/repositories/releases/</url>    
       </repository>    
       <snapshotRepository>    
           <id>commanyRep-snapshot</id>    
           <url>http://localhost:8080/nexus/content/repositories/snapshots/</url>    
       </snapshotRepository>    
  </distributionManagement>

  用户名密码可以改为具有部署构件权限的用户。
  7.2)执行命令:mvn clean deploy

8、手动部署构件到Nexus仓库
  在nexus的仓库列表中点击要部署的目标仓库,然后点击Artifact Upload选项卡,选择文件上传。

转载于:https://www.cnblogs.com/yuanyee/p/6253025.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值