一、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文件中添加镜像文件关联

  1. <mirrors>
  2. <mirror>
  3. <id>nexus-releases</id>
  4. <mirrorOf>*</mirrorOf>
  5. <url>http://localhost:8081/nexus/content/groups/public</url>
  6. </mirror>
  7. <mirror>
  8. <id>nexus-snapshots</id>
  9. <mirrorOf>*</mirrorOf>
  10. <url>http://localhost:8081/nexus/content/repositories/apache-snapshots/</url>
  11. </mirror>
  12. </mirrors>

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

  1. </profiles>
  2.   <profile>
  3. <id>nexusTest</id>
  4. <repositories>
  5. <repository>
  6. <id>local-nexus</id>
  7. <url>http://127.0.0.1:8081/nexus/content/groups/public/</url>
  8. <releases>
  9. <enabled>true</enabled>
  10. </releases>
  11. <snapshots>
  12. <enabled>true</enabled>
  13. </snapshots>
  14. </repository>
  15. </repositories>
  16. </profile>
  17. </profiles>

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

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

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

1.在pom.xml中添加

  1. <distributionManagement>
  2. <!--自己创建的库-->
  3. <repository>
  4. <id>myReposioryT</id><!--这里的id与角色中配置的id要一致-->
  5. <name>my test reposiory</name>
  6. <url> http://localhost:8081/nexus/content/repositories/myRepository</url>
  7. </repository>
  8. <!--snapshots库-->
  9. <snapshotRepository>
  10. <id>nexus-snapshots</id>
  11. <name>Nexus Snapshot Repository</name>
  12. <url>http://127.0.0.1:8081/nexus/content/repositories/snapshots/</url>
  13. </snapshotRepository>
  14. <!--<repository>
  15. <id>nexus-releases</id>
  16. <name>Nexus Release Repository</name>
  17. <url>http://127.0.0.1:8081/nexus/content/repositories/releases/</url>
  18. </repository>
  19. -->
  20. </distributionManagement>

1.在settings.xml文件中添加

  1. <servers>
  2. <server>
  3. <id>myReposioryT</id> <!-- 这里的id要与pom.xml中的一致 表示使用该账号上传jar到自己建立的my test reposiory仓库中-->
  4. <username>testAdmin</username>
  5. <password></password>
  6. </server>
  7. <server>
  8. <id>nexus-releases</id>
  9. <username>admin</username>
  10. <password>admin123</password>
  11. </server>
  12. <server>
  13. <id>nexus-snapshots</id>
  14. <username>admin</username>
  15. <password>admin123</password>
  16. </server>
  17. </servers>

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

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

附录:

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

2.如果我们版本号后面有后最SNAPSHOT,如<version>1.1-SNAPSHOT</version>

我们即使是发布到release版本,nexus还是会自动认为是snapshot版本。处理的方式有两种。

2.1直接去掉版本号后面的SNAPSHOT后缀,如:<version>1.1</version>

2.2使用如下配置

  1. //头部版本号的配置
  2. <version>${project.release.version}</version>
  3.  
  4. //添加properties
  5. <properties>
  6. <project.release.version>1.1-SNAPSHOT</project.release.version>
  7. </properties>
  8.  
  9. <profiles>
  10. <profile>
  11. <id>myRelease</id> <!--id自己随便取 使用mvn命令发布的时候要使用到这个id-->
  12. <properties>
  13. <project.release.version>1.1</project.release.version>
  14. </properties>
  15. </profile>
  16. </profiles>

发布的时候使用命令 mvn deploy -P myRelease  (myRelease是profile取得id值)

这样发布的时候会使用我们在profile中定义的properties中的变量值去替换<version></version>中的值

nexus 的使用及maven的配置的更多相关文章

  1. Nexus Repository3安装和maven,npm配置(Linux)

    Nexus Repository下载 根据操作系统选择指定版本,本文针对Linux安装,其他的安装过程可能有所差异. https://help.sonatype.com/repomanager3/do ...

  2. 国内可用maven repository 配置

    国内可用maven repository 配置 发表于2016/1/4 23:08:04  10235人阅读 分类: maven 鉴于一些原因,从maven中央仓库download依赖包时,被各种折磨 ...

  3. maven的安装,maven库配置和Eclipse插件的安装

    maven的安装,maven库配置和Eclipse插件的安装 1.下载并解压maven 2.配置环境变量 3.配置maven配置文件 1.下载链接 Downloading Apache Maven 2 ...

  4. Maven 私服配置 转

    1.配置Nexus为maven的私服 第一种方式:在项目的POM中如下配置 <repositories>     <repository>         <id> ...

  5. 开发流程和Maven的配置

    按照何种开发模型? V模型:项目需求--->概要设计(功能模块) --->详细设计(页面的设计,数据库的设计) --->编码(框架的搭建,功能的实现)---->测试(单元测试, ...

  6. Nexus 私有仓库搭建与 Maven 集成

    Nexus 私有仓库搭建与 Maven 集成 |作者:RexFang |出处:http://www.cnblogs.com/rexfang/ |关于作者:Java 程序员一枚 |版权:本文版权归作者和 ...

  7. Eclipse上Maven环境配置使用 (全)

    Eclipse上Maven环境配置使用 (全) 1. 安装配置Maven: 1.1 从Apache网站 http://maven.apache.org/ 下载并且解压缩安装Apache Maven. ...

  8. 阿里云Maven配置,Maven仓库配置,Maven镜像配置

    阿里云Maven配置,Maven仓库配置,Maven镜像配置 ======================== 蕃薯耀 2018年1月29日 http://www.cnblogs.com/fanshu ...

  9. 在Eclipse上Maven环境配置使用

    1. 安装配置Maven: 1.1 从Apache网站 http://maven.apache.org/ 下载并且解压缩安装Apache Maven. Maven下载地址: http://maven. ...

随机推荐

  1. HTML&CSS基础学习笔记1.30-颜色的表达

    颜色的表述 在网页中的颜色设置是非常重要,CSS的属性有字体颜色(color).背景颜色(background-color).边框颜色(border)等,设置颜色的方法也有很多种: 1.英文命令颜色 ...

  2. FCKEditor使用说明

    1.基本设置   先看看效果是什么样的:   效果图: 那么为什么说是FCKeditor的冰冷之心呢?这不是哗众取宠,主要是说它使用起来有点麻烦,下文就详细说明如何搞定这玩意儿. 1.FCKedito ...

  3. js 冒泡事件的处理

    onMouseOver 和 onMouseOut事件冒泡 当事件在某一DOM元素被触发时,例如用户在某个节点上点击鼠标,事件将跟随着该节点继承的各个父节点冒泡穿过整个DOM的节点层次,直到它遇到依附有 ...

  4. Linux——搭建PHP开发环境第二步:PHP

    原文链接:http://www.2cto.com/os/201511/450258.html ##### PHP 编译安装 #### [root@localhost ~]# yum install l ...

  5. FileUpload 改变控件显示的文字

    浏览

  6. 之前C#代码的重新设计

    /* 我用python重构了一把这个代码 大家的反应似乎是过度设计了 好吧,我决定不那么激进,采用更中庸一些的重构 我也有些疑惑: 是否如果重构后的代码比重构前要多,就算过度了呢? */ void m ...

  7. 转:基于科大讯飞语音API语音识别开发详解

    原文来自于: http://www.52wulian.org/android_voice/ 最近项目需要用到android语音识别,立马就想到科大讯飞,结合官方实例及阅读API文档,初步的完成了And ...

  8. (未解决)问题记录ionic android 签名之后安装到手机上点击运行出现闪退,不签名运行正常

    Log日志如下: - ::): error opening trace ) - ::): FATAL EXCEPTION: main - ::): java.lang.RuntimeException ...

  9. 【HDOJ】1438 钥匙计数之一

    状态压缩.分最后一个槽的值以及当前的配置方案是否可以进行DP. /* 1438 */ #include <cstdio> #include <cstring> #include ...

  10. COJN 0558 800600带通配符的字符串匹配

    800600带通配符的字符串匹配 难度级别:B: 运行时间限制:1000ms: 运行空间限制:51200KB: 代码长度限制:2000000B 试题描述 通配符是一类键盘字符,当我们不知道真正字符或者 ...