nexus 的使用及maven的配置
一、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></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>
附录:
1.如果使用idea,则有很好的工具帮我们操作

2.如果我们版本号后面有后最SNAPSHOT,如<version>1.1-SNAPSHOT</version>
我们即使是发布到release版本,nexus还是会自动认为是snapshot版本。处理的方式有两种。
2.1直接去掉版本号后面的SNAPSHOT后缀,如:<version>1.1</version>
2.2使用如下配置
//头部版本号的配置
<version>${project.release.version}</version> //添加properties
<properties>
<project.release.version>1.1-SNAPSHOT</project.release.version>
</properties> <profiles>
<profile>
<id>myRelease</id> <!--id自己随便取 使用mvn命令发布的时候要使用到这个id-->
<properties>
<project.release.version>1.1</project.release.version>
</properties>
</profile>
</profiles>
发布的时候使用命令 mvn deploy -P myRelease (myRelease是profile取得id值)
这样发布的时候会使用我们在profile中定义的properties中的变量值去替换<version></version>中的值
nexus 的使用及maven的配置的更多相关文章
- Nexus Repository3安装和maven,npm配置(Linux)
Nexus Repository下载 根据操作系统选择指定版本,本文针对Linux安装,其他的安装过程可能有所差异. https://help.sonatype.com/repomanager3/do ...
- 国内可用maven repository 配置
国内可用maven repository 配置 发表于2016/1/4 23:08:04 10235人阅读 分类: maven 鉴于一些原因,从maven中央仓库download依赖包时,被各种折磨 ...
- maven的安装,maven库配置和Eclipse插件的安装
maven的安装,maven库配置和Eclipse插件的安装 1.下载并解压maven 2.配置环境变量 3.配置maven配置文件 1.下载链接 Downloading Apache Maven 2 ...
- Maven 私服配置 转
1.配置Nexus为maven的私服 第一种方式:在项目的POM中如下配置 <repositories> <repository> <id> ...
- 开发流程和Maven的配置
按照何种开发模型? V模型:项目需求--->概要设计(功能模块) --->详细设计(页面的设计,数据库的设计) --->编码(框架的搭建,功能的实现)---->测试(单元测试, ...
- Nexus 私有仓库搭建与 Maven 集成
Nexus 私有仓库搭建与 Maven 集成 |作者:RexFang |出处:http://www.cnblogs.com/rexfang/ |关于作者:Java 程序员一枚 |版权:本文版权归作者和 ...
- Eclipse上Maven环境配置使用 (全)
Eclipse上Maven环境配置使用 (全) 1. 安装配置Maven: 1.1 从Apache网站 http://maven.apache.org/ 下载并且解压缩安装Apache Maven. ...
- 阿里云Maven配置,Maven仓库配置,Maven镜像配置
阿里云Maven配置,Maven仓库配置,Maven镜像配置 ======================== 蕃薯耀 2018年1月29日 http://www.cnblogs.com/fanshu ...
- 在Eclipse上Maven环境配置使用
1. 安装配置Maven: 1.1 从Apache网站 http://maven.apache.org/ 下载并且解压缩安装Apache Maven. Maven下载地址: http://maven. ...
随机推荐
- 01:Hello, World!
描述 对于大部分编程语言来说,编写一个能够输出“Hello, World!”的程序往往是最基本.最简单的.因此,这个程序常常作为一个初学者接触一门新的编程语言所写的第一个程序,也经常用来测试开发.编译 ...
- iOS开发——OC篇&常用关键字的使用与区别
copy,assign,strong,retain,weak,readonly,readwrite,nonatomic,atomic,unsafe_unretained的使用与区别 最近在学习iOS的 ...
- mobile plugin
http://fronteed.com/iCheck/ http://spritely.net/documentation/ http://www.mobilexweb.com/blog/mobile ...
- 高效率dc升壓轉換器 應用技巧談 功率設計
為便攜式電子設備開發電源電路要求設計工程師通過最大程度地提高功率和降低整個系統的功耗來延長電池使用壽命,這推動器件本身的尺寸變得更小,從而有益于在設計終端產品時獲得更高靈活性.這種設計的最重要元器件之 ...
- BitmapFactory.decodeResource(res, id); 第一个参数跟第二个参数有什么关系?
BitmapFactory.decodeResource(res, id); res= getResources();activity的方法 id = R.drawable.x
- cursor pin S wait on X
cursor pin S wait on X: 这是10.2版本提出的mutex(互斥)机制用来解决library cache bin latch争夺问题引入的新事件,是否使用这种机制受到隐含参数_k ...
- BZOJ1708: [Usaco2007 Oct]Money奶牛的硬币
1708: [Usaco2007 Oct]Money奶牛的硬币 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 513 Solved: 329[Submi ...
- delphi 自定义消息
delphi 自定义消息 消息描述 Tmsg是 Windows系统用来记录描述一个具体的windows消息的.就是windows 用于封装应用程序及系统程序发生的消息,它是操作系统使用 ...
- [LeetCode] 219. Contains Duplicate II 解题思路
Given an array of integers and an integer k, find out whether there are two distinct indices i and j ...
- selenium webdriver python 元素定位
总结 定位查找时,返回查找到的第一个match的元素.如果找不到,则 raise NoSuchElementException 单个元素定位: find_element_by_idfind_e ...