11.3. Maven POM

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

Page Views: 9 views

POM (Project Object Model, Project object Model) is the basic unit of work of the Maven project. It is a XML file that contains basic information about the project, which describes how the project is built, declares project dependencies, and so on.

When performing a task or target, Maven looks for POM in the current directory. It reads the POM, gets the required configuration information, and then executes the target.

The following configurations can be specified in POM:

  • Project dependence

  • Plug-in

  • Executive goal

  • Project build profile

  • Project version

  • List of project developers

  • Related mailing list information

Before creating a POM, we first need to describe the project team (groupId), the unique ID of the project.

4.0.0com.companyname.project-groupproject1.0    

All POM files require the project element and three required fields: groupId,artifactId,version.

Node

Description

Project

The root label of the project.

ModelVersion

The model version needs to be set to 4.0.

GroupId

This is the logo of the engineering team. It is usually unique in an organization or project. For example, a banking organization, com.companyname.project-group, owns all the bank-related projects.

ArtifactId

This is the logo of the project. It is usually the name of the project. For example, consumer banks. GroupId and artifactId together define the location of artifact in the warehouse.

Version

This is the version number of the project. In the artifact repository, it is used to distinguish between different versions. For example:

com.company.bank:consumer-banking:1.0 com.company.bank:consumer-banking:1.1 

11.3.1. Parent (Super) POM

Parent (Super) POM is the default POM for Maven. All POM inherits from a parent POM (whether or not the parent POM is explicitly defined). The parent POM contains some default settings that can be inherited. Therefore, when Maven finds that it needs to download a dependency in POM, it goes to the default repository http://repo1.maven.org/maven2 configured in Super POM to download it.

Maven uses effective pom (Super pom plus the project’s own configuration) to implement related goals, which helps developers make as few configurations as possible in pom.xml, which can of course be rewritten.

Use the following command to view the Super POM default configuration:

mvn help:effective-pom 

Next, we create the directory MVN/project, and create a pom.xml under that directory, as follows:

4.0.0com.companyname.project-groupproject1.0    

In the command console, go to the MVN/project directory and execute the following command:

C:\MVN\project>mvn help:effective-pom 

Maven will start processing and display the effective-pom.

[INFO] Scanning for projects... Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom ... [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 01:36 min [INFO] Finished at: 2018-09-05T11:31:28+08:00 [INFO] Final Memory: 15M/149M [INFO] ------------------------------------------------------------------------ 

The results of Effective POM, as shown in the console, are inherited and interpolated to make the configuration take effect.

4.0.0com.companyname.project-groupproject1.0C:\MVN\project\src\main\javasrc/main/scriptsC:\MVN\project\src\test\javaC:\MVN\project\target\classesC:\MVN\project\target\test-classesresource-0C:\MVN\project\src\main\resourcesresource-1C:\MVN\project\src\test\resourcesC:\MVN\project\targetproject-1.0maven-antrun-plugin1.3maven-assembly-plugin2.2-beta-2maven-clean-plugin2.2maven-compiler-plugin2.0.2maven-dependency-plugin2.0maven-deploy-plugin2.4maven-ear-plugin2.3.1maven-ejb-plugin2.1maven-install-plugin2.2maven-jar-plugin2.2maven-javadoc-plugin2.5maven-plugin-plugin2.4.3maven-rar-plugin2.2maven-release-plugin2.0-beta-8maven-resources-plugin2.3maven-site-plugin2.0-beta-7maven-source-plugin2.0.4maven-surefire-plugin2.4.3maven-war-plugin2.1-alpha-2maven-help-plugin2.1.1falsecentralMaven Repository Switchboardhttp://repo1.maven.org/maven2neverfalsecentralMaven Plugin Repositoryhttp://repo1.maven.org/maven2C:\MVN\project\target/site    

In the above pom.xml, you can see the default project source directory structure, output directory, required plug-ins, warehouse and report directory that Maven needs to use to execute the target.

The pom.xml file for Maven also does not need to be written by hand.

Maven provides a large number of prototype plug-ins to create projects, including engineering structures and pom.xml.

11.3.2. A detailed explanation of POM tags

4.0.0asia.banseonbanseon-maven2jar1.0-SNAPSHOTbanseon-mavenhttp://www.baidu.com/banseonA maven project to study maven.jirahttp://jira.baidu.com/banseon
Demobanseon@126.combanseon@126.combanseon@126.comhttp:/hi.baidu.com/banseon/demo/dev/HELLO WORLDbanseonbanseon@126.comProject ManagerArchitectdemohttp://hi.baidu.com/banseonNo-5Apache 2http://www.baidu.com/banseon/LICENSE-2.0.txtrepoA business-friendly OSS licensescm:svn:http://svn.baidu.com/banseon/maven/banseon/banseon-maven2-trunk(dao-trunk)scm:svn:http://svn.baidu.com/banseon/maven/banseon/dao-trunkhttp://svn.baidu.com/banseondemohttp://www.baidu.com/banseon............Windows XPWindowsx865.1.2600mavenVersion2.0.3/usr/local/hudson/hudson-home/jobs/maven-guide-zh-to-production/workspace//usr/local/hudson/hudson-home/jobs/maven-guide-zh-to-production/workspace/....................................banseon-repository-proxybanseon-repository-proxyhttp://192.168.1.169:9999/repository/default......org.apache.mavenmaven-artifact3.8.1jartestspring-coreorg.springframeworktrue......banseon-maven2banseon maven2file://${basedir}/target/deploybanseon-maven2Banseon-maven2 Snapshot Repositoryscp://svn.baidu.com/banseon:/usr/local/maven-snapshotbanseon-sitebusiness api websitescp://svn.baidu.com/banseon:/var/www/localhost/banseon-web
《地理信息系统原理、技术与方法》  97

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