码迷,mamicode.com
首页 > 其他好文 > 详细

nexus 的使用及maven的配置

时间:2015-12-10 14:54:42      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:

一、nexus的安装

1.下载nexus(点解这里)

2.下载后解压文件,将解压后的nexus文件放在你自己想要的地方

3.配置环境变量(和配置java的环境变量一样)

技术分享

技术分享

4.安装和启动nexus

技术分享

由于我已经安装和启动过nexus,所以有错误信息提示

5.启动成功后,在浏览器输入http://localhost:8081/nexus/就会进入nexus的操作界面

技术分享

我们也可以在conf/nexus.properties修改端口

技术分享

6.用admin登录成功后,可以看到如下界面

技术分享

我们可以看见type有多重类型,这里我们介绍三种:

  • hosted,本地仓库(也叫宿主仓库),通常我们会部署自己的构件到这一类型的仓库或则是第三方的包(如:oracel的)。
  • proxy,代理仓库,它们被用来代理远程的公共仓库,如maven中央仓库。
  • group,仓库组,用来合并多个hosted/proxy仓库,通常我们配置maven依赖仓库组。

二、使用nexus的管理界面上传jar包

技术分享

 

三、创建自己的私有仓库

技术分享

 技术分享

四、创建权限

技术分享

 

五、创建角色

技术分享技术分享

技术分享

五、创建用户

技术分享技术分享技术分享

六、关联自己的私有仓库

1.在settings.xml文件中添加镜像文件关联

  <mirrors>
    <mirror>     
      <id>nexus-releases</id>     
      <mirrorOf>*</mirrorOf>     
      <url>http://localhost:8081/nexus/content/groups/public</url>     
    </mirror> 
     <mirror>     
       <id>nexus-snapshots</id>     
      <mirrorOf>*</mirrorOf>     
       <url>http://localhost:8081/nexus/content/repositories/apache-snapshots/</url>     
     </mirror> 
  </mirrors>

2.在settings.xml文件中设置profile

  </profiles>    
    <profile>  
        <id>nexusTest</id>  
        <repositories>  
          <repository>  
            <id>local-nexus</id>  
            <url>http://127.0.0.1:8081/nexus/content/groups/public/</url>  
            <releases>  
              <enabled>true</enabled>  
            </releases>  
            <snapshots>  
              <enabled>true</enabled>  
            </snapshots>  
          </repository>  
        </repositories>  
      </profile>  
  </profiles>


  <activeProfiles> <!--激活id为nexusTest的profile-->
    <activeProfile>nexusTest</activeProfile>
  </activeProfiles>

 

七、发布自己的快照版本到私有仓库

这里我们测试将的nexusTest.jar发布到myRepository仓库中

1.在pom.xml中添加

<distributionManagement>
        <!--自己创建的库-->
       <repository>
            <id>myReposioryT</id><!--这里的id与角色中配置的id要一致-->
            <name>my test reposiory</name>
            <url> http://localhost:8081/nexus/content/repositories/myRepository</url>
        </repository>
        <!--snapshots库-->
        <snapshotRepository>
            <id>nexus-snapshots</id>
            <name>Nexus Snapshot Repository</name>
            <url>http://127.0.0.1:8081/nexus/content/repositories/snapshots/</url>
        </snapshotRepository>
      <!--<repository>
            <id>nexus-releases</id>
            <name>Nexus Release Repository</name>
            <url>http://127.0.0.1:8081/nexus/content/repositories/releases/</url>
        </repository>
       -->
    </distributionManagement>

1.在settings.xml文件中添加

    <servers>  
         <server>  
            <id>myReposioryT</id> <!-- 这里的id要与pom.xml中的一致  表示使用该账号上传jar到自己建立的my test reposiory仓库中-->
            <username>testAdmin</username>  
            <password>123456</password>  
          </server>  
      <server>  
        <id>nexus-releases</id>  
        <username>admin</username>  
        <password>admin123</password>  
      </server>  
      <server>  
        <id>nexus-snapshots</id>  
        <username>admin</username>  
        <password>admin123</password>  
      </server>     
    </servers>  

使用maven的package deploy 命令就可以将自己的项目打成jar包发布到自己的私有仓库。

注意,要发布jar包,需要将修改 <packaging>war</packaging>为 <packaging>jar</packaging>

附录:

如果使用idea,则有很好的工具帮我们操作

技术分享

 

nexus 的使用及maven的配置

标签:

原文地址:http://www.cnblogs.com/mouseIT/p/5035345.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!