我对Maven快照的含义有点困惑,为什么我们要构建一个?
当前回答
understanding the context of SDLC will help understand the difference between snapshot and the release. During the dev process developers all contribute their features to a baseline branch. At some point the lead thinks enough features have accumulated then he will cut a release branch from the baseline branch. Any builds prior to this time point are snapshots. Builds post to this point are releases. Be noted, release builds could change too before going to production if any defect spot during the release testing.
其他回答
Maven中的快照版本是尚未发布的版本。
其思想是,在1.0发行版(或任何其他发行版)完成之前,存在1.0- snapshot。这个版本可能会变成1.0。它基本上是“正在开发的1.0版本”。这可能接近于真正的1.0发行版,或者相当远(例如,就在0.9发行版之后)。
“真实”版本和快照版本之间的区别是快照可能会得到更新。这意味着今天下载1.0-SNAPSHOT的文件可能与昨天或明天下载的文件不同。
通常,快照依赖关系应该只存在于开发过程中,没有发布版本(即没有非快照版本)应该依赖于快照版本。
我想谈谈术语。其他答案很好地解释了什么是Maven上下文中的“快照”版本。但是,非快照版本是否应该被称为“发布”版本呢?
在“发布”版本的语义版本控制思想之间存在一些紧张关系,“发布”版本似乎是任何没有-SNAPSHOT这样的限定符,但也没有-beta.4这样的限定符的版本;以及Maven的“发布”版本的想法,它似乎只包括没有-SNAPSHOT。
In other words, there is a semantic ambiguity of whether "release" means "we can release it to Maven Central" or "the software is in its final release to the public". We could consider -beta.4 to be a "release" version if we release it to the public, but it's not a "final release". Semantic versioning clearly says that something like -beta.4 is a "pre-release" version, so it wouldn't make sense for it to be called a "release" version, even without -SNAPSHOT. In fact by definition even -rc.5 is a release candidate, not an actual release, even though we may allow public access for testing.
因此,尽管Maven如此,在我看来,只将“发布”版本称为根本没有任何限定符(甚至没有-beta.4)的版本似乎更合适。对于Maven非快照版本来说,更好的名称可能是“稳定”版本(灵感来自另一个答案)。这样我们就有:
1.2.3-beta。4-SNAPSHOT:预发布版本的快照版本。 1.2.3-SNAPSHOT:发布版本的快照版本。 1.2.3-beta。4:预发布版本的稳定版本。 1.2.3:发布版本(显然是一个稳定的非快照版本)。
A Maven SNAPSHOT is an artifact created by a Maven build and pretends to help developers in the software development cycle. A SNAPSHOT is an artifact (or project build result ) that is not pretended to be used anywhere, it's only a temporarily .jar, ear, ... created to test the build process or to test new requirements that are not yet ready to go to a production environment. After you are happy with the SNAPSHOT artifact quality, you can create a RELEASE artifact that can be used by other projects or can be deployed itself.
在你的项目中,你可以使用Maven的pom.xml文件中的version元素定义一个SNAPSHOT:
<groupId>example.project.maven</groupId>
<artifactId>MavenEclipseExample</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<description>Maven pom example</description>
如果你想更好地理解Maven,你也可以看看这些文章:
https://connected2know.com/programming/menu-maven-articles/
通常在maven中,我们有两种类型的构建 1)建立快照 2)制定版本发布
快照构建:快照是特殊版本,它指示当前部署副本,不像常规版本,maven检查远程存储库中的每个构建的版本 因此快照构建只是开发构建。 发布版本:发布意味着在版本中删除快照,这些是常规的构建版本。
SNAPSHOT值指的是沿着开发分支的“最新”代码,并不能保证代码是稳定的或不变的。相反,“发布”版本(任何不带SNAPSHOT后缀的版本值)中的代码是不变的。
换句话说,SNAPSHOT版本是最终“发布”版本之前的“开发”版本。SNAPSHOT比它的发行版“更老”。
在发布过程中,x.y-SNAPSHOT的一个版本更改为x.y。发布过程还将开发版本增加到x.(y+1)-SNAPSHOT。例如,版本1.0- snapshot发布为版本1.0,新的开发版本为版本1.1-SNAPSHOT。
推荐文章
- Java 8接口方法中不允许“同步”的原因是什么?
- 如何找到Java堆大小和内存使用(Linux)?
- 使用Enum实现单例(Java)
- RabbitMQ与通道和连接之间的关系
- buildSessionFactory()配置方法在Hibernate中已弃用?
- Spring MVC -如何获得所有的请求参数在一个地图在Spring控制器?
- 如何在Java中按两个字段排序?
- 文件之间的差异。路径中的分隔符和斜杠
- 在方法参数中使用NotNull注释
- Spring MVC中处理可选参数的@RequestParam
- 禁用maven下载进度指示
- Tomcat:如何查找正在运行的Tomcat版本?
- “java”、“javaw”和“javaws”之间有什么区别?
- 将Date对象转换为日历对象
- 在Java中保存最后N个元素的大小有限的队列