我对Maven快照的含义有点困惑,为什么我们要构建一个?


当前回答

在开发阶段,Maven快照每天都会寻找更新的更高版本(如果在nexus存储库中可用),然后在本地下载它以备下一次构建。

您可以在存储库定义中设置四个选项

总是这样, 每日(默认), 间隔, 永远,

注意:在产品版本中,我们不应该依赖于快照版本。

其他回答

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

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

在开发阶段,Maven快照每天都会寻找更新的更高版本(如果在nexus存储库中可用),然后在本地下载它以备下一次构建。

您可以在存储库定义中设置四个选项

总是这样, 每日(默认), 间隔, 永远,

注意:在产品版本中,我们不应该依赖于快照版本。

Maven中的快照版本是尚未发布的版本。

其思想是,在1.0发行版(或任何其他发行版)完成之前,存在1.0- snapshot。这个版本可能会变成1.0。它基本上是“正在开发的1.0版本”。这可能接近于真正的1.0发行版,或者相当远(例如,就在0.9发行版之后)。

“真实”版本和快照版本之间的区别是快照可能会得到更新。这意味着今天下载1.0-SNAPSHOT的文件可能与昨天或明天下载的文件不同。

通常,快照依赖关系应该只存在于开发过程中,没有发布版本(即没有非快照版本)应该依赖于快照版本。

这就是存储库的快照的样子,在本例中没有启用快照,这意味着这里引用的存储库是稳定的,不需要更新。

<project>
    ...
    <repositories>
        <repository>
            <id>lds-main</id>
            <name>LDS Main Repo</name>
            <url>http://code.lds.org/nexus/content/groups/main-repo</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
</project>

另一种情况是:

<snapshots>
        <enabled>true</enabled>
</snapshots>

这意味着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.