我对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.

其他回答

“快照”术语意味着构建是给定时间内代码的快照。

这通常意味着这个版本仍在大量开发中。

当代码准备好并且是时候发布它时,您将希望更改POM中列出的版本。然后,您将使用“1.0”这样的标签,而不是使用“SNAPSHOT”。

有关版本控制的帮助,请查看语义版本控制规范。

SNAPSHOT值指的是沿着开发分支的“最新”代码,并不能保证代码是稳定的或不变的。相反,“发布”版本(任何不带SNAPSHOT后缀的版本值)中的代码是不变的。

换句话说,SNAPSHOT版本是最终“发布”版本之前的“开发”版本。SNAPSHOT比它的发行版“更老”。

在发布过程中,x.y-SNAPSHOT的一个版本更改为x.y。发布过程还将开发版本增加到x.(y+1)-SNAPSHOT。例如,版本1.0- snapshot发布为版本1.0,新的开发版本为版本1.1-SNAPSHOT。

通常在maven中,我们有两种类型的构建 1)建立快照 2)制定版本发布

快照构建:快照是特殊版本,它指示当前部署副本,不像常规版本,maven检查远程存储库中的每个构建的版本 因此快照构建只是开发构建。 发布版本:发布意味着在版本中删除快照,这些是常规的构建版本。

顾名思义,快照指的是项目的状态及其在那个时刻的依赖关系。每当maven找到一个较新的项目SNAPSHOT时,它就下载并替换本地存储库中较旧的项目.jar文件。

快照版本用于正在进行开发的项目。如果您的项目依赖于正在积极开发的软件组件,那么您可以依赖于快照发布,并且当您运行构建时,Maven将定期尝试从存储库下载最新的快照。

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/