11.13. Maven Snapshot (SNAPSHOT)

发布时间 :2025-10-25 12:23:16 UTC      

A large software application usually contains multiple modules, and the usual scenario is that multiple teams develop different modules of the same application. For example, imagine that one team develops the front end of the application and the project is app-ui (app-ui.jar:1.0), while the background of another team developing the application uses the project data-service (data-service.jar:1.0).

What may happen now is that the team that developed data-service is doing fast-paced bug fixes or project improvements, and they publish the library to the remote repository almost every other day. Now if the data-service team uploads a new version every other day, the following problems will arise:

  • The data-service team informs the app-ui team every time the updated code is released.

  • The app-ui team needs to update their pom.xml files to the latest version frequently.

In order to solve this situation, 快照 The concept came in handy.

11.13.1. What is a snapshot?

A snapshot is a special version that specifies a copy of the current development progress. Unlike the regular version, Maven checks for new snapshots in the remote repository with each build. Now the data-service team publishes a snapshot of the updated code to the repository, such as data-service:1.0-SNAPSHOT, to replace the old snapshot jar package.

11.13.2. Project Snapshot vs version

For versions, if Maven has previously downloaded the specified version file, for example, data-service:1.0,Maven will not download the new available version 1.0 file from the repository. To download the updated code, the version of data-service needs to be upgraded to 1.1.

In the case of snapshots, each time the app-ui team builds their project, Maven automatically takes the latest snapshot (data-service:1.0-SNAPSHOT).

11.13.3. Pom.xml file for app-ui project

The app-ui project uses a 1.0 snapshot of the data-service project.

<projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>app-ui</groupId><artifactId>app-ui</artifactId><version>1.0</version><packaging>jar</packaging><name>health</name><url>http://maven.apache.org</url><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties><dependencies><dependency><groupId>data-service</groupId><artifactId>data-service</artifactId><version>1.0-SNAPSHOT</version><scope>test</scope></dependency></dependencies></project>

11.13.4. Pom.xml file for data-service project

The data-service project releases 1. 0 snapshots for each small change.

<projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>data-service</groupId><artifactId>data-service</artifactId><version>1.0-SNAPSHOT</version><packaging>jar</packaging><name>health</name><url>http://maven.apache.org</url><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties></project>

Although, in the case of snapshots, Maven automatically takes the latest snapshots in its daily work, you can use the-U parameter in any maven command to force maven to download the latest snapshot builds.

mvn clean package -U

Let’s open the command console, go to the C:> MVN > app-ui directory, and execute the following mvn command.

C:\MVN\app-ui>mvn clean package -U

Maven will start building the project after downloading the latest snapshot of data-service.

[INFO] Scanning for projects...
[INFO] -------------------------------------------------------------------
[INFO] Building consumerBanking
[INFO]    task-segment: [clean, package]
[INFO] -------------------------------------------------------------------
[INFO] Downloading data-service:1.0-SNAPSHOT
[INFO] 290K downloaded.
[INFO] [clean:clean {execution: default-clean}]
[INFO] Deleting directory C:\MVN\app-ui\target
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\MVN\app-ui\src\main\
resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Compiling 1 source file to C:\MVN\app-ui\target\classes
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\MVN\app-ui\src\test\
resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] Compiling 1 source file to C:\MVN\app-ui\target\test-classes
[INFO] [surefire:test {execution: default-test}]
[INFO] Surefire report directory: C:\MVN\app-ui\target\
surefire-reports
-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.companyname.bank.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.027 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO] [jar:jar {execution: default-jar}]
[INFO] Building jar: C:\MVN\app-ui\target\
app-ui-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Tue Jul 10 16:52:18 IST 2012
[INFO] Final Memory: 16M/89M
[INFO] ------------------------------------------------------------------------
Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.