maven中snapshot快照库和releasemaven 发布快照库的区别和作用

maven中snapshot快照库和release发布库的区别和作用_百度知道maven中snapshot快照库和release发布库的区别和作用_百度知道其它(35)
[转载声明] 转载时必须标注:本文来源于铁木箱子的博客http://www.mzone.cc
[本文地址] 本文永久地址是:
&&&&& 之前有过几篇文章介绍了mavven中release和snapshot库的作用,如下(不太了解的可以参考看一下):
&&&&& 另外,今天在使用snapshot快照库时遇到一个问题,我一个构件的发布配置如下(在构件的pom文件中):
&modelVersion&4.0.0&/modelVersion&&groupId&cc.mzone&/groupId&&artifactId&workflow&/artifactId&&version&0.1-SNAPSHOT&/version&&packaging&jar&/packaging&&distributionManagement&
&repository&
&id&kt&/id&
&url&http://192.168.1.112/nexus/content/repositories/kt&/url&
&/repository&
&snapshotRepository&
&id&kt-snapshot&/id&
&url&http://192.168.1.112/nexus/content/repositories/kt-snapshot&/url&
&uniqueVersion&true&/uniqueVersion&
&/snapshotRepository&&/distributionManagement&
&&&&& 这个是构件的发布配置,其中snapshot快照库中使用了uniqueVersion为true,这个表明每次发布都会在服务器上留下一个新版本(加上时间后缀的版本)。这个true和false不影响快照库,只是是否节省服务器空间的问题。在通过mvn deploy发布到服务器后,在依赖该构件的项目的pom文件中写上依赖:
&dependency&
&groupId&cc.mzone&/groupId&
&artifactId&workflow&/artifactId&
&version&0.1-SNAPSHOT&/version&&/dependency&
&&&&& 然后在该项目中执行:mvn eclipse:eclipse进行其依赖构件的下载,结果却发现提示如下:
[WARNING] An error occurred during dependency resolution.
Failed to retrieve cc.mzone:workflow-<span style="color:#.1-SNAPSHOTCaused by: Unable to download the artifact from any repository Try downloading the file manually from the project website.
&&&&& 刚开始不太清楚原因,经过查证比对,发现是因为项目没有开启snapshot快照库的缘故!知道了原因,解决就好办了,有两种方法可以解决:
1、第一种方法是在项目的pom文件中进行配置,如下:
&repositories&
&repository&
&id&cc-mzone-nexus&/id&
&name&MZONE&/name&
&url&http://192.168.1.112/nexus/content/groups/public/&/url&
&snapshots&
&enabled&true&/enabled&
&updatePolicy&interval:5&/updatePolicy&
&/snapshots&
&/repository&&/repositories&
2、第二种方法是在maven的配置文件(conf/settings.xml)中进行配置,如下:
&profiles&
&id&cc-mzone-profile&/id&
&repositories&
&repository&
&id&cc-mzone-nexus&/id&
&name&MZONE&/name&
&url&http://192.168.1.112/nexus/content/groups/public/&/url&
&releases&
&enabled&true&/enabled&
&/releases&
&snapshots&
&enabled&true&/enabled&
&updatePolicy&interval:10&/updatePolicy&
&/snapshots&
&/repository&
&/repositories&
&/profile&&/profiles&&activeProfiles&
&activeProfile&cc-mzone-profile&/activeProfile&&/activeProfiles&
&&&&& 以上两种方式都是打开snapshot快照库,允许快照库生效(重要就是snapshot中enabled要设置为true),第一种是项目级别的,第二种是全局的。出现的问题当然主要还是默认snapshot快照库是没有生效导致的,如此配置即可解决
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:279679次
积分:4498
积分:4498
排名:第4618名
原创:157篇
转载:175篇
评论:38条
(2)(5)(5)(4)(1)(4)(1)(8)(2)(2)(2)(2)(4)(2)(2)(1)(1)(1)(1)(12)(21)(1)(1)(1)(6)(4)(2)(1)(4)(10)(5)(1)(5)(6)(4)(6)(2)(3)(1)(20)(5)(4)(1)(1)(6)(16)(9)(7)(11)(17)(5)(6)(11)(11)(27)(19)(2)}

我要回帖

更多关于 snapshot release 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信