Maven发布项目到Nexus私服中 (发布jar包)
1 需求说明
开发完项目后, 将项目版本发布到Nexus私服中.
2 实现步骤
2.1 Maven服务的setting.xml文件
(1) 如果本机安装了Maven服务, 可在${MAVEN_HOME}/conf/setting.xml中指定私服相关的配置:
<!-- 在servers标签下配置server, 包括: 私服的用户名和密码, 在deploy项目时需要用到 -->
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
<!-- 在profiles标签下配置profile, 包括: 私服所配的仓库、各个插件的仓库地址 -->
<profile>
<!-- profile的id -->
<id>dev</id>
<repositories>
<repository>
<!-- 仓库id, Repositories可以配置多个仓库, 要确保id不重复 -->
<id>nexus</id>
<!-- 仓库地址, 即nexus仓库组的地址 -->
<url>http://ip:port/nexus/content/groups/public/</url>
<!-- 是否下载Releases构件 -->
<releases>
<enabled>true</enabled>
</releases>
<!-- 是否下载Snapshots构件 -->
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<!-- 插件仓库, Maven的运行依赖插件, 也需要从私服下载插件 -->
<pluginRepository>
<!-- 插件仓库的id不允许重复, 如果重复, 后配置的优先 -->
<id>public</id>
<name>Public Repositories</name>
<url>http://ip:port/nexus/content/groups/public/</url>
</pluginRepository>
</pluginRepositories>
</profile>
<!-- 还需指定联网仓库, 保证本私服中没有相关jar包或插件时可联网获取 -->
<profile>
<id>internet</id>
<repositories>
<repository>
<id>nexus-aliyun</id>
<name>Nexus aliyun</name>
<layout>default</layout>
<!-- 这里配置阿里云的仓库 -->
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
</profile>
(2) 如果本机没有安装Maven服务, 可在IDEA或Eclipse等开发环境默认使用的Maven配置中修改, 修改内容同上.
2.2 项目的pom.xml文件
在项目的pom.xml中的一级标签project下添加如下内容:
<!-- 发布选项: id必须与setting.xml文件中server的id相同 -->
<distributionManagement>
<repository>
<id>releases</id>
<name>display</name>
<url>http://ip:port/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>display</name>
<url>http://ip:port/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
2.3 发布项目
以IDEA为例, 选中项目, 右键 -> Run Maven -> deploy,
或者在右边栏选中Maven栏目, 点击项目 -> Lifecycle -> deploy, 执行即可将项目发布到仓库中去.
注意: 仓库中不能存在与当前项目名称+版本号相同的项目, 否则将导致出错: Bad Request: 400.
版权声明
作者: 马瘦风
出处: 博客园 马瘦风的博客
感谢阅读, 如果文章有帮助或启发到你, 点个[好文要顶
Maven发布项目到Nexus私服中 (发布jar包)的更多相关文章
- 解决eclipse中maven web工程打包成war(发布到tomcar)时lib中没有jar包的解决方法
可能有两个原因:1.maven中某些jar包下载不下来 从其他地方下载jar文件放到相应maven本地库的.m2里2..classpath文件中缺少(下面代码的作用是制定maven的jar发布路径)& ...
- 如何在maven项目的pom.xml文件中添加jar包
在使用maven进行项目开发时,我们需要在pom.xml文件中添加自己所需要的jar包.这就要求我们获取jar包的groupId和artifactId. 我们可以在一些maven仓库上搜索我们所需要的 ...
- Maven 本地仓库同步到私服中
步骤: 第一步:找到安装私服的目录中plexus.properties文件. 地址:C:\Windows\apache-tomcat-7.0.26\webapps\nexus-2.7.0-06\WEB ...
- maven之发布项目到nexus【clean deploy命令】
原文:http://m.blog.csdn.net/article/details?id=49667971 当我们的项目开发完成以后,可能要进行发布(如果是独立的项目,就不需要发布啦,如果是模块项目, ...
- maven私服nexus上传第三方jar包以及下载
私服是一个特殊的远程仓库,它是架设在局域网内的仓库服务.私服代理广域网上的远程仓库,供局域网内的Maven用户使用.当Maven需要下载构建的使用,它先从私服请求,如果私服上没有的话,则从外部的远程仓 ...
- [解决]UserLibrary中的jar包不会自动发布Tomcat的lib目录下(基于MyEclipse2014)
1.在工程名称上单击[右键] —— 单击[Properties]选项,点击后会弹出属性窗口: 2.选择[Properties]后在左侧树中找到[MyEclipse] —— [Deployment As ...
- Intellij IDEA 中如何查看maven项目中所有jar包的依赖关系图(转载)
Intellij IDEA 中如何查看maven项目中所有jar包的依赖关系图 2017年04月05日 10:53:13 李学凯 阅读数:104997更多 所属专栏: Intellij Idea ...
- maven本地仓库中存在jar包,但编译不成功,显示jar包不存在
介绍一下背景,项目要迁移进坑人的离线的内网开发,将在同事那编译通过的代码和maven仓库拷进内网,打算编译通过之后再上传私服,结果配好maven之后,本地库中的部分jar包显示没有引入,如下面的波浪线 ...
- 如何在maven中添加jar包
Maven 中央仓库地址: 1. http://www.sonatype.org/nexus/ 2. http://mvnrepository.com/ (本人推荐仓库) 3. http://repo ...
随机推荐
- C# 异步委托的使用
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threa ...
- 同时使用SpringJUnit4ClassRunner和Parameterized进行参数化
标题实际上是个不可能完成的任务,因为我们只能用一个Runwith注解,而且只能写一个类,但是我们可以曲线救国,插入下方的5到14行就可以注入了 @ContextConfiguration(classe ...
- RelativeSource 简述
原文:RelativeSource 简述 RelativeSource实现标记扩展,以描述绑定源相对于绑定目标的位置. <Binding> <Binding.RelativeSour ...
- WPF常见内存泄露
Event handlers leak This type of leak occurs when subscribing an object (let's call it listener) to ...
- SQL Server修改标识列方法(备忘)
原文:SQL Server修改标识列方法(备忘) SQL Server修改标识列方法 ----允许对系统表进行更新 exec sp_configure 'allow updates',1 reconf ...
- SQL Server 可更新订阅中有行筛选的同步复制移除项目而不重新初始化所有订阅!
原文:SQL Server 可更新订阅中有行筛选的同步复制移除项目而不重新初始化所有订阅! 在可更新订阅的同步复制中,有行筛选的项目表,移除的时候会提示重新初始化所有的快照并且应用此快照,这将导致所有 ...
- Windows 10 (IIS 10)安装Microsoft Web Farm Framework Version 2.2 for IIS7问题
But I got an error message "iis version 7.0 or greater is required to install Web Farm Framewor ...
- 记一次ASP.NET MVC4 升级到MVC5的小问题解决
原文:记一次ASP.NET MVC4 升级到MVC5的小问题解决 .NET 4.0 MVC4版本,升级到.NET 4.6.1 MVC5: 1.使用nuget更新所有 与mvc相关的类库; 2.更改~/ ...
- 在Azure中搭建Ghost博客并绑定自定义域名和HTTPS
绪论 之前一直使用cnblog写博客,现在将博客迁移至Microsoft Azure上的Ghost博客上,Ghost博客使用Markdown书写博客,页面简洁,是我喜欢的风格.具体参见官网:https ...
- git + gerrit push 代码问题
关于refs/for 和 refs/heads: 1. 这个不是git的规则,而是gerrit的规则, 2. Branches, remote-tracking branches, a ...