There are two kinds of warehouses in maven, snapshot warehouse and publishing warehouse. Snapshot snapshot warehouse is used to store unstable versions in the development process, and release formal warehouse is used to store stable release versions. To define a component/module as a snapshot version, just add -SNAPSHOT after the module version number in the pom file (note that it must be capitalized here), as shown below:
& ltgroupId & gtcc.mzone & lt/groupId & gt;
& ltartifactId & gtm 1 & lt; /artifact id & gt;
& lt/version & gt;. 1- snapshot & lt/version >
& lt packaging & gtjar & lt/ packaging & gt
Maven2 will judge whether it is a snapshot version or an official version according to whether there is a -SNAPSHOT in the version number of the module (the version in the pom file). If it is a snapshot version, mvn will be automatically published to the snapshot version library when it is deployed, while maven will automatically download the latest snapshot version from the mirror server when compiling and packaging the module that directly uses the snapshot version, without changing the version number. If the version is officially released, it will be automatically released to the official version library when MVN is deployed. However, if the official version module is used, it will not be downloaded from the mirror server actively when compiling and packaging, and the version number will not be changed.
Therefore, in the development stage, we can set the version of the public library as the snapshot version, and rely on components to reference the snapshot version for development. After the snapshot version of the public library is updated, we can download the new version without modifying the version number indicated in the pom file. We can directly execute related compiling and packaging commands in mvn, and download the latest snapshot library again, which is also convenient for our development.