maven项目部署到Repository(Nexus)
本文将以开源的Nexus为例,演示如何将自己开发的项目部署到Nexus Repository中,解决项目发布、升级的问题。
(一)下载并安装Nexus
Nexus只需下载war包放到tomcat服务器上便可。

(二)配置Nexus Repository
- 打开WEB管理界面:http://localhost:8081/nexus/index.html
- 点击右上角Log In进行登录,默认帐号:admin、密码:admin123
- 点击左侧Repositories项 -> central仓库 -> Configuration -> Download Remote Indexes=True -> Save,表示下载远程仓库的索引。
- 右键central仓库 -> Update Index,更新远程仓库索引到本地,这一步能够加速本地索引。
说明:
- 新搭建的neuxs环境只是一个空的仓库,
需要手动和远程中心库进行同步,nexus默认是关闭远程索引下载,最重要的一件事情就是开启远程索引下载。 找到右边仓库列表中的三个仓库Apache
Snapshots,Codehaus Snapshots和Maven
Central,然后再没有仓库的configuration下把Download Remote
Indexes修改为true。然后在这三个仓库上分别右键,选择Repari Index,这样Nexus就会去下载远程的索引文件。右键仓库
-> Update Index,更新远程仓库索引到本地,这一步能够加速本地索引。
- 新建公司的内部仓库,步骤为
Repositories –> Add –> Hosted Repository,在页面的下半部分输入框中填入Repository
ID和Repository Name即可,另外把Deployment Policy设置为Allow Redeploy
- Nexus中仓库组的概念是Maven没有
的,在Maven看来,不管你是hosted也好,proxy也好,或者group也好,对我都是一样的,我只管根据
groupId,artifactId,version等信息向你要构件。为了方便Maven的配置,Nexus能够将多个仓库,hosted或者
proxy合并成一个group,这样,Maven只需要依赖于一个group,便能使用所有该group包含的仓库的内容。
(三)在项目中配置Nexus Repository的信息
- 项目pom文件配置distributionManagement
|
1
2
3
4
5
6
7
8
9
10
11
12
|
<distributionManagement> <repository> <id>releases</id> <name>Nexus Release Repository</name> <url>http://localhost:8081/nexus/content/repositories/releases/</url> </repository> <snapshotRepository> <id>snapshots</id> <name>Nexus Snapshot Repository</name> <url>http://localhost:8081/nexus/content/repositories/snapshots/</url> </snapshotRepository></distributionManagement> |
- settings.xml配置账号密码。注意server的id与repository的id必须对应
|
1
2
3
4
5
6
7
8
9
10
11
12
|
<servers> <server> <id>releases</id> <username>admin</username> <password>admin123</password> </server> <server> <id>snapshots</id> <username>admin</username> <password>admin123</password> </server></servers> |
(四)发布到Nexus Repository
- 项目中执行mvn deploy,成功如下所示
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ tenpay ---
Uploading: http://localhost:8081/nexus/content/repositories/releases/com/capital/tenpay/1.2/tenpay-1.2.jar
Uploading: http://localhost:8081/nexus/content/repositories/releases/com/capital/tenpay/1.2/tenpay-1.2.pom
Uploaded: http://localhost:8081/nexus/content/repositories/releases/com/capital/tenpay/1.2/tenpay-1.2.pom (2 KB at 9.7 KB/sec)
Uploaded:
http://localhost:8081/nexus/content/repositories/releases/com/capital/tenpay/1.2/tenpay-1.2.jar
(39 KB at 124.4 KB/sec)
Downloading: http://localhost:8081/nexus/content/repositories/releases/com/capital/tenpay/maven-metadata.xml
Downloaded:
http://localhost:8081/nexus/content/repositories/releases/com/capital/tenpay/maven-metadata.xml
(347 B at 4.3 KB/sec)
Uploading: http://localhost:8081/nexus/content/repositories/releases/com/capital/tenpay/maven-metadata.xml
Uploaded: http://localhost:8081/nexus/content/repositories/releases/com/capital/tenpay/maven-metadata.xml (376 B at 7.8 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS

maven项目部署到Repository(Nexus)的更多相关文章
- maven项目如何从私服nexus中下载依赖包
maven项目如何从私服nexus中下载依赖包 解决方法: 1.打开maven的config目录中settings.xml文件 2.在<profile></profiles> ...
- eclipse中maven项目部署到tomcat
其实maven项目部署到tomcat的方式很多,我从一开始的打war包到tomcat/webapps目录,到使用tomcat-maven插件,到直接使用servers部署,一路来走过很多弯路. 下面就 ...
- eclipse中maven项目部署到tomcat [转]
其实maven项目部署到tomcat的方式很多,我从一开始的打war包到tomcat/webapps目录,到使用tomcat-maven插件,到直接使用servers部署,一路来走过很多弯路. 下面就 ...
- [转]maven项目部署到tomcat
其实maven项目部署到tomcat的方式很多,我从一开始的打war包到tomcat/webapps目录,到使用tomcat-maven插件,到直接使用servers部署,一路来走过很多弯路. 下面就 ...
- maven项目部署到tomcat方法
今天记录下,maven项目部署到服务器的过程 1.首先在ide中里将自己的maven项目打包 mvn clean install 2. 看是否需要修改war包的名字,如果要修改,就用命令 mv xxx ...
- 有关使用Maven常见问题总结(Eclipse中使用Maven、Maven项目部署到tomcat等问题)
http://blog.csdn.net/sunitjy/article/details/42709311 ********************************************** ...
- Maven项目部署方案
以xbank项目做为应用背景,简单说明一下Maven项目的部署方案: 1.项目说明 xbank基础服务端的11个子项目均采用Maven搭建: 其中各项目功能设计如下: froad-xbank-serv ...
- Maven入门,Maven项目的创建,nexus 2.x搭建私服以及Maven多模块项目创建
maven的了解做一个总结,以便日后查阅, 若有不足之处,还望指出,学无止境 当然也能起到入门效果. 一,搭建maven私服 1.工具 a. Nexus 2.5.1-01 b. Maven 3.3.9 ...
- maven项目部署到Tomcat
1.安装Tomcat,地址:http://tomcat.apache.org,我安装的版本为9.0.0.M22,安装的目录为C:\apache-tomcat,设置环境变量CATALINA_HOME为C ...
随机推荐
- matrix67:kmp算法详解
个人认为KMP是最没有必要讲的东西,因为这个东西网上能找到很多资料.但网上的讲法基本上都涉及到“移动(shift)”.“Next函数”等概念,这非常容易产生误解(至少一年半前我看这些资料学习KMP时就 ...
- 如何优化cocos2d/x内存使用和程序大小的程序
从最初的:http://www.himigame.com/iphone-cocos2d/1043.html 译者: 在我完毕第一个游戏项目的时候.我深切地意识到"使用cocos2d来制作游戏 ...
- Linux下which、whereis、locate、find 区别
我们经常在linux要查找某个文件或命令,但不知道放在哪里了,可以使用下面的一些命令来搜索.which 查看可执行文件的位置 whereis 查看文件的位置 locate 配合 ...
- git 使用过程(四、回退版本)
1.查看修改历史 命令:git log 如果嫌内容太多 可以加参数 --pretty=oneline (图一) 2.回退 命令:git reset --hard HEAD^ HEAD:代表本 ...
- Codeforces Round #316 (Div. 2A) 570A Elections
题目:Click here #include <bits/stdc++.h> using namespace std; typedef long long ll; const int IN ...
- c++, 派生类的构造函数和析构函数 , [ 以及operator=不能被继承 or Not的探讨]
说明:文章中关于operator=实现的示例,从语法上是对的,但逻辑和习惯上都是错误的. 参见另一篇专门探究operator=的文章:<c++,operator=>http://www.c ...
- javascript (string 部分)
<html> <body> <script type="text/javascript"> var str="ab:cd:ef:gh& ...
- hibernate报错
报错二:java.lang.ExceptionInInitializerError java.lang.ExceptionInInitializerError at com.java1234.serv ...
- Qt 获取字符串的UTF8编码值
看到群里有人在问怎么获取字符串的UTF8编码值 自己测试了下 熟悉下函数 <span style="font-size:18px;"> ui->setupU ...
- 莱特币ltc在linux下的多种挖矿方案详解
莱特币ltc在linux下的多种挖矿方案详解 4.0.1 Nvidia显卡Linux驱动Nvidia全部驱动:http://www.nvidia.cn/Download/index.aspx?lang ...