11.16. Maven automated deployment

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

During the project development process, the deployment process includes the following steps:

  • Submit the project code to SVN or code library and tag it.

  • Download the complete source code from SVN.

  • Build the application.

  • Store the build output WAR or EAR files to a common network location.

  • Get the file from the network and deploy the file to the production site.

  • Update the document and update the version number of the application.

11.16.1. Problem description

In general, multiple teams are involved in the development process mentioned above. One team may be responsible for submitting code, another team for building, and so on. It is likely that any step can go wrong due to the human operations and multi-team environments involved. For example, the older version was not updated on the network machine, and then the deployment team redeployed the earlier build.

11.16.2. Solution

Automate deployment by combining the following scenarios:

  • Build and publish projects using Maven

  • Use SubVersion, source code repository to manage source code

  • Use remote warehouse management software (Jfrog or Nexus) to manage project binaries.

11.16.3. Modify the pom.xml of the project

We will use plug-ins released by Maven to create an automated release process.

For example, the pom.xml file code for the bus-core-api project is as follows:

<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>bus-core-api</groupId><artifactId>bus-core-api</artifactId><version>1.0-SNAPSHOT</version><packaging>jar</packaging><scm><url>http://www.svn.com</url><connection>scm:svn:http://localhost:8080/svn/jrepo/trunk/
Framework</connection><developerConnection>scm:svn:${username}/${password}@localhost:8080:
common_core_api:1101:code</developerConnection></scm><distributionManagement><repository><id>Core-API-Java-Release</id><name>Release
repository</name><url>http://localhost:8081/nexus/content/repositories/
Core-Api-Release</url></repository></distributionManagement><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-release-plugin</artifactId><version>2.0-beta-9</version><configuration><useReleaseProfile>false</useReleaseProfile><goals>deploy</goals><scmCommentPrefix>[bus-core-api-release-checkin]-</scmCommentPrefix></configuration></plugin></plugins></build></project>

Some of the important element nodes that we often use in the pom.xml file are shown in the following table:

Element node

Description

SCM

Configure the path to SVN from which Maven will remove the code.

Repository

The location of the built WAR or EAR or JAR file, or the storage location of the artifacts generated after the other source code is built successfully.

Plugin

Configure the maven-release-plugin plug-in to automate the deployment process.

11.16.4. Maven Release plug-in

Maven uses the maven-release-plugin plug-in to accomplish the following tasks.

mvn release:clean

Clean up the workspace to ensure the success of the latest release process.

mvn release:rollback

If the last release process is unsuccessful, rolling back the modified workspace code and configuration ensures that the release process is successful.

mvn release:prepare

Perform a variety of actions:

  • Check to see if there are any local changes that have not yet been committed

  • Make sure there are no dependencies for snapshots

  • Change the version information of the application for release

  • Update the POM file to SVN

  • Run the test case

  • Submit the modified POM file

  • Mark the code on SVN

  • Increase the version number and attach snapshots for future release

  • Submit the modified POM file to SVN

mvn release:perform

Switch the code to where it was previously marked and run the Maven deployment target to deploy the WAR file or build the corresponding structure into the repository.

Open the command terminal, go to the C:> MVN > bus-core-api directory, and execute the following mvn command.

C:\MVN\bus-core-api>mvn release:prepare

Maven began to build the entire project. After the build is successful, you can run the following mvn command.

C:\MVN\bus-core-api>mvn release:perform

After the build is successful, you can verify that the JAR file uploaded under your repository is valid.

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.