The difference and function of the snapshot snapshot library and the release release library in maven

Although it is not used in the development stage now, in fact, after it is finalized, it becomes a finished product, and the code can be assigned a version number. Indicates that this version of the code is maintained in a unified, under this version, they are all available. It is useful for all parent and managed child modules to ensure unity.

http://www.mzone.cc/article/277.html
quote


In the process of using maven, we often have many public libraries in an unstable state during the development phase, which need to be modified and released at any time. It may be released once a day, and even N times a day when bugs are encountered. We know that maven's dependency management is based on version management. For the artifact in the release state, if the version number is the same, even if the components on our internal mirror server are newer than the local, maven will not actively download them. If we are doing dependency management based on the officially released version in the development stage, then when we encounter this problem, we need to upgrade the version number of the component, but this obviously does not meet the requirements and actual situation. However, if it is based on the snapshot version, then the problem is solved spontaneously, and maven has prepared all this for us.

      There are two kinds of warehouses in maven, snapshot snapshot warehouse and release release warehouse. The snapshot repository is used to store unstable versions in the development process, and the official release repository is used to store stable releases. To define a component/module as a snapshot version, you only need to add -SNAPSHOT after the version number of the module in the pom file (note that it must be capitalized), as follows:

<groupId>cc.mzone</groupId>
<artifactId >m1</artifactId>
<version>0.1-SNAPSHOT</version>
<packaging>jar</packaging>
      maven2 will judge whether it is a snapshot version or an official version according to whether the version number of the module (version in the pom file) has -SNAPSHOT. If it is a snapshot version, it will be automatically published to the snapshot repository when mvn deploy, and when using the snapshot version of the module, without changing the version number, when compiling and packaging directly, maven will automatically download the latest version from the mirror server. Snapshot version. If it is an official release version, it will be automatically released to the official version library when mvn deploy, and using the official version of the module, without changing the version number, if the module of this version already exists locally when compiling and packaging, it will not be Actively go to the mirror server to download.

      Therefore, in the development phase, we can set the version of the public library as the snapshot version, and the dependent components refer to the snapshot version for development. After the snapshot version of the public library is updated, we do not need to modify the pom file to prompt the version number to download For the new version, you can re-download the latest snapshot library by directly executing the relevant compilation and packaging commands in mvn, which also facilitates our development.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326222933&siteId=291194637