项目中应用snapshot和release库

应用snapshot和release库达到不同环境下发布不同的版本的目的:

1,自动打包到私服:

在pom.xml中配置

<!-- 配置maven部署库:在distributionManagement段中配置的是snapshot快照库和release发布库的地址-->
<distributionManagement>
<repository>
<id>releases</id>
<url>${nexus.root}/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>${nexus.root}/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

<!-- 参数配置 -->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<nexus.root>http://192.168.0.15:8081/nexus</nexus.root>
</properties>

cmd控制台切换到pom.xml项目空间下:

执行命令: mvn deploy   就可以将当前项目打成所需要的格式自动上传到0.15私服里面.

2,启动项目自动更新最新的包:

配置maven的setting文件

添加如下代码:

(1)配置servers:

<server>
<id>thirdparty</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>

(2)配置profiles:

<profile>
<id>nexus</id>
<repositories>
<repository>
<id>public</id>
<url>http://192.168.0.15:8081/nexus/content/groups/public/</url>
<release><enabled>true</enabled></release>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>public</id>
<url>http://192.168.0.15:8081/nexus/content/groups/public/</url>
<release><enabled>true</enabled></release>
<snapshots>
<enabled>true></enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>

 

posted on 2017-02-22 13:57  低调后的华丽  阅读(398)  评论(0编辑  收藏  举报

导航