使用 Maven 部署 artifact 到 Nexus 教程
本文侧重讲解如何将已经按照好的 Maven 和 Nexus 连接,即如何通过 Maven 部署 artifact 到 Nexus。
本文前提:
1. 安装好 Maven。可以使用 Maven 创建、打包项目。关于安装
2. 安装好 Nexus。可以访问本地的 Nexus 仓库 http://localhost:8081/nexus/#welcome 。
正文:
1. 配置 Maven 的配置文件 settings.xml 和 项目的说明文件 pom.xml ,使得 Maven 知道往哪里部署 ,已经有权限部署 。
在 setting.xml 中 :
<servers>
<server>
<id>xxx-nexus</id>
<username>deployment</username>
<password>{deployment_pwd}</password>
</server>
</servers>
建议使用 deployment 账号,这个账号在安装好 Nexus 后就有了,默认密码是 deployment123 , 可以修改此密码。
在 pom.xml 中 :
<distributionManagement>
<!-- Publish the versioned releases here -->
<repository>
<id>xxx-nexus</id>
<name>vineetmanohar nexus</name>
<url>http://localhost:8081/nexus/content/repositories/releases/</url>
</repository> <!-- Publish the versioned releases here -->
<snapshotRepository>
<id>xxx-nexus</id>
<name>vineetmanohar nexus</name>
<url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
注意一,这里 <repository> 元素 和 <snapshotRepository> 元素的 id 应该和 settings.xml 中的 id 保持一致,使得库位置 和 库账号密码能对的上。
注意二, <repository> 元素的 url 和 <snapshotRepository> 元素的 url 应该应该是不一样的。我第一次配置的时候把上面的 url 值直接 copy 到下面的 url ,导致报错 :
Could not transfer artifact com.tony.aaa:webTT:war:1.0-20160124.105254- from/to vineetmanohar-nexus (http://localhost:/nexus/content/repositories/releases/) ...... Return code is: , ReasonPhrase: Bad Request.
2. 添加部署插件
使用 nexus-staging-maven-plugin 插件,使得部署更顺利。
在 pom.xml 中:
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.5.1</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
<configuration>
<serverId>nexus</serverId>
<nexusUrl>http://localhost:8081/nexus/</nexusUrl>
<skipStaging>true</skipStaging>
</configuration>
</plugin>
</plugins>
3. 执行部署命令
mvn clean deploy -Dmaven.test.skip=true
执行完后,应该看到类似的 :
....
Uploading: http://localhost:8081/nexus/content/repositories/snapshots/com/tony/aaa/webTT/maven-metadata.xml
Uploaded: http://localhost:8081/nexus/content/repositories/snapshots/com/tony/aaa/webTT/maven-metadata.xml (275 B at 13.4 KB/sec)
[INFO] * Bulk deploy of locally gathered snapshot artifacts finished.
[INFO] Remote deploy finished with success.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.689 s
[INFO] Finished at: 2016-01-24T21:12:28+08:00
[INFO] Final Memory: 16M/240M
[INFO] ------------------------------------------------------------------------
表示部署成功。然后可以到 Nexus 看到类似如下的结果 :
至此,部署完成。
参考资料 :
Maven Deploy to Nexus, Baelduang ,Maven 部署教程
"Bad Request" Error when deploying an artifact in Nexus
Getting started with Nexus Maven Repo Manager, Vineet Manohar's blog ,很好的教程,其中包含如何配置 Nexus 安全
Repository Management with Nexus 看了前三章,了解了关于 Nexus 的基本概念
Maven Tutorial - TutorialsPoint 很好的教程,看完能大致了解和使用 Maven.
Welcome to Apache Maven, Apache Maven 官网,关于 Maven 的细节可以在里面查找。
使用 Maven 部署 artifact 到 Nexus 教程的更多相关文章
- maven项目部署到Repository(Nexus)
目录[-] (一)下载并安装Nexus (二)配置Nexus Repository 说明: (三)在项目中配置Nexus Repository的信息 (四)发布到Nexus Repository 本文 ...
- Maven部署异常:on project standalone-pom: Cannot deploy artifact from the local repository解决方法
MAVEN部署异常 org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache. ...
- Gradle Maven部署,转化
参考:(易百教程)http://www.yiibai.com/gradle/gradle_deployment.html 目录: Gradle部署 Maven转化为Gradle Gradle部署: c ...
- maven之如何将自己的写的 maven 构件发布到 nexus 私服
概念:Nexus服务器是一个代码包管理的服务器,可以理解 Nexus 服务器是一个巨大的 Library 仓库.Nexus 可以支持管理的工具包括 Maven , npm 等,对于 JAVA 开发来说 ...
- 阿里云运维部署工具AppDeploy详细教程
AppDeploy是一个通过SSH实现的命令行工具,可完成应用部署和远程运维管理.当前工具实现为两个版本:普通版(伪代码描述语言)和Python版.Python版使用Python语法规则,可实现您的各 ...
- 使用Maven部署构件至私服
--------------------siwuxie095 使用 Maven 部署构件至私服 1.部署构件到 Nexu ...
- maven部署tomcat项目,403错误解决
maven部署tomcat项目时403错误的解决方法 web模块的pom文件 pom.xml <plugin> <groupId>org.apache.tomcat.maven ...
- maven部署命令
参考文档:http://blog.csdn.net/woshixuye/article/details/8133050 http://www.blogjava.net/itvincent/archiv ...
- 抗忙,,建个MAVEN的私服仓库-NEXUS
公司最近需求越来越上轨道,MAVEN的私服仓库-NEXUS构架起来哟.. 参考文档URL: http://www.linuxidc.com/Linux/2011-07/39578p3.htm http ...
随机推荐
- Linux基本权限
首先需要我们了解的是,权限(rwx)对于文件和目录的作用是不一样的 . 权限对文件的作用 r : 读取文件内容(cat , more , head , tail) w: 编辑.新增.修改文件内容(vi ...
- iOS加载启动图的时候隐藏statusbar + 指定启动图显示多少秒
只需需要在info.plist中加入Status bar is initially hidden 设置为YES 补充一下,现在手机越来越快,在6+下面启动图一闪而过,而美工童鞋辛辛苦苦做的图就看不到鸟 ...
- UITableView-FDTemplateLayoutCell自动计算UITableView高度的使用
基本应用如果你有self-satisfied cell,那么你应该做的是:#import "UITableView+FDTemplateLayoutCell.h"- (CGFloa ...
- Active控件有关问题
ActiveX 控件是允许网站提供视频等内容的网站. 当你浏览 Web 时,它们允许你使用工具栏.股票代号.视频和其它内容. 但是,这些程序有时可能出现问题,或者向你提供不需要的内容. 在某些情况下, ...
- 网络编程Socket之UDP
服务器端实现步骤: 1. 创建 DatagramSocket,指定端口号 2. 创建 DatagramPacket 3. 接收客户端发送的数据信息 4. 读取数据 package cn.jmu.edu ...
- Objective-C中的协议(Protocol)和类别(Category)
1.什么是协议? 2.协议与类别的声明和使用 1.什么是协议? 在Objective-C中,不支持多继承,即不允许一个类有多个父类,但是OC提供了类似的实现方法,也就是协议.协议有点类似于Java里的 ...
- 使用xshell出现乱码
用xshell链接Linux出现乱码: 解决方法: 先查看Linux支持的字符类型是否为如下类型 如果是,则找到菜单中的文件选项,并在选项中找到属性: 单击属性选项,找到终端,将编码设置为UTF-8: ...
- 如何根据Jquery实现两级联动
<script language="javascript" type="text/javascript" > $(function (){ ...
- Python学习笔记:04函数
Python 函数 通过分而治之的方法解决问题是一种很自然的思路.函数就是将解决特定问题的方法进行抽象. def fibs(num): 'calculate the first num th fib ...
- JQUERY 常用方法大全
Attribute: $("p").addClass(css中定义的样式类型); 给某个元素添加样式 $("img").attr({src:"test ...