11.16. Maven automated deployment

发布时间 : 2025-10-25 13:35:07 UTC      

Page Views: 14 views

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:

4.0.0bus-core-apibus-core-api1.0-SNAPSHOTjarhttp://www.svn.comscm:svn:http://localhost:8080/svn/jrepo/trunk/ Frameworkscm:svn:${username}/${password}@localhost:8080: common_core_api:1101:codeCore-API-Java-ReleaseRelease repositoryhttp://localhost:8081/nexus/content/repositories/ Core-Api-Releaseorg.apache.maven.pluginsmaven-release-plugin2.0-beta-9falsedeploy[bus-core-api-release-checkin]-    

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.

《地理信息系统原理、技术与方法》  97

最近几年来,地理信息系统无论是在理论上还是应用上都处在一个飞速发展的阶段。 GIS被应用于多个领域的建模和决策支持,如城市管理、区划、环境整治等等,地理信息成为信息时代重要的组成部分之一; “数字地球”概念的提出,更进一步推动了作为其技术支撑的GIS的发展。 与此同时,一些学者致力于相关的理论研究,如空间感知、空间数据误差、空间关系的形式化等等。 这恰好说明了地理信息系统作为应用技术和学科的两个方面,并且这两个方面构成了相互促进的发展过程。