使用 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 ...
随机推荐
- Html----常见标签
文本格式化标签 标签 描述 <b> 定义粗体文本. <big> 定义大号字. <em> 定义着重文字. <i> 定义斜体字. <small> ...
- Android的GridView和Gallery结合Demo
Android的GridView和Gallery结合Demo Demo介绍:首页是一个GridView加载图片,竖屏时显示3列图片,横屏时显示4列图片;并且对图片进行大小限制和加灰色边框处理. 点击某 ...
- call, apply, bind作用
call, apply作用就是(改变方法中的this指向)借用别人的方法来调用,就像调用自己的一样 function Person(name) { this.name = name; } Person ...
- HTML (1)href与Action,get post
1. href与Action的区别 href只能get参数,action能get参数又能post参数 href一般用于单个连接,可以带参数(URL重写),是采用get方式请求的,在地址栏中可以看到 ...
- response.setContentType()的作用及参数
package com.java1234.util; import java.io.PrintWriter; import javax.servlet.http.HttpServletResponse ...
- myeclipse跟eclipse中使用github做版本控制工具
今天早上花了一上午的时间,了解了在myeclipse跟eclipse中使用github. 好吧 说说怎么做的,让大伙少走一点路,我就简单描述下,需要软件的私信我 第一:下载git 第二:靠谱.但是pu ...
- SSIS学习计划
百科:SSIS是Microsoft SQL Server Integration Services的简称,是生成高性能数据集成解决方案(包括数据仓库的提取.转换和加载 (ETL) 包)的平台. htt ...
- asp.net微信开发第五篇----用户分组管理
上一篇已讲解到新建用户分组,移动用户到分组的功能,这一章主要讲解修改分组名称和删除分组 开发者可以使用接口,对公众平台的分组进行查询.创建.修改.删除等操作,也可以使用接口在需要时移动用户到某个分组. ...
- exp、imp简单测试
imp 分为以下几个测试场景 imp name1/password1 file=xxxx.dmp full=y fromuser=name2 touser=name3 场景1 name1正确.pas ...
- Sql Server 远程过程调用失败
很多搞开发的同志们,相信在刚刚使用sql server2008+c#2012(2012以上版本)会出现下面图片中的问题,这时因为安装Visual Studio 2013或者2012版本的时候,会自动安 ...