maven 教程五 将项目发布到私服
2016-04-12 17:02
447 查看
1 . 修改私服中仓库的部署策略
Release版本的项目应该发布到Releases仓库中,对应的,Snapshot版本应该发布到Snapshots仓库中。Maven根据pom.xml文件中版本号<version>节点的属性是否包含-SNAPSHOT,来判断该项目是否是snapshot版本。如果是snapshot版本,在执行mvn deploy部署命令时,maven会自动将项目发布到Snapshots仓库。要发布项目,首先需要将Releases仓库和Snapshots仓库的“Deployment Policy”设置为“Allow Redeploy”:2 . 配置项目的部署仓库
在pom.xml中分别对Release版本和Snapshot版本配置部署仓库,其中id唯一,url分别对应私服中Releases和Snapshots仓库的Repository Path:<uniqueVersion>表示是否为Snapshot版本分配一个包含时间戳的构建号,效果如下:
<distributionManagement>
<snapshotRepository>
<id>user-snapshot</id>
<name>User Porject Snapshot</name>
<url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
<uniqueVersion>true</uniqueVersion>
</snapshotRepository>
<repository>
<id>user-release</id>
<name>User Porject Release</name>
<url>http://localhost:8081/nexus/content/repositories/releases/</url>
</repository>
</distributionManagement>
3 . 启用Deployment用户
Nexus默认有三个用户,其中Deployment用户用于部署项目:Deployment用户默认密码为deployment123,右键菜单可修改或重置密码:
在settings.xml中分别为上面配置的部署仓库配置server,其中id需要分别对应上面的部署仓库id:
<servers>
<server>
<id>user-release</id>
<username>deployment</username>
<password>deployment123</password>
</server>
<server>
<id>user-snapshot</id>
<username>deployment</username>
<password>deployment123</password>
</server>
</servers>
4 . 发布项目
右键pom.xml - Run As - 2 Maven build...发布成功后,在私服的仓库中就能看到了:
5 . 在Nexus中手动上传项目构件
在Nexus仓库的Artifact Upload选项卡中,填写相关信息,可以手动的方式上传项目构件:注:但是现在还是无法使用私服下载依赖,还需要配置如下内容在setting.xml 文件中:
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
OK,现在一个私服就搭建成功了。
原文链接:Maven入门指南⑥:将项目发布到私服
相关文章推荐
- java学习之反射
- HDU 3829 二分最大独立集
- Windows Dev Intro - Direct2D Compile Error
- Your project path contains non-ASCII characters(使用androidstudio常见错误)
- git基本使用
- netstat使用详解
- Android控件EditText的属性InputType的一些经验及动态设置TYPE_NUMBER_FLAG_DECIMAL无效的原因
- tomcat(6)生命周期
- zzulioj 1862: 我叫叶良辰 (Lucas推广)
- asp.net 点击服务器按钮 不触发后台事件解决方法
- JQuery实现提交(submit)表单时候验证所有文本框是否为空
- 小公司如何做项目管理?
- Android 通知栏Notification的整合 全面学习 (一个DEMO让你完全了解它)
- 代理设计模式(一)静态代理
- Sql Server触发器案例(初学者学习案例)
- STM32 待机唤醒
- MemCache超详细解读
- hbase
- 计算函数运行时间
- ThinkPHP 3.2.3 验证码 生成和校验DEMO