Maven pom.xml File Structure
Maven pom.xml File Structure
Maven is a build automation tool for Java projects. The pom.xml file is the main configuration file for Maven projects. It stands for “Project Object Model” and contains information about the project and configuration details used by Maven to build the project.
Basic File Structure of pom.xml
The structure and main components of pom.xml are as follows:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="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/POM/4.0.0/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.testingdocs.example</groupId>
<artifactId>my-maven-app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>My Maven Application</name>
<description>A simple Maven project</description>
<dependencies>
<!-- Dependencies go here -->
</dependencies>
<build>
<plugins>
<!-- Plugins go here -->
</plugins>
</build>
</project>
Explanation of File Structure
<?xml version=”1.0″ encoding=”UTF-8″?>
This line declares the XML version and encoding.
<project>
The root element of the pom.xml file.
xmlns and xsi:schemaLocation
These attributes define the XML namespaces and schema location for validation. Maven uses them to understand and validate the structure of the POM file.
<modelVersion>
Specifies the version of the POM model. The value 4.0.0 is the current version.
<groupId>
Defines the group or organization that the project belongs to. It’s like a namespace for your project artifacts (e.g., com.testingdocs.example).
<artifactId>
The name of the project or module. This is the identifier for the project artifact (e.g., my-app).
<version>
The version of the project artifact (e.g., 1.0-SNAPSHOT). The SNAPSHOT suffix indicates that it is a development version.
<packaging>
Specifies the type of artifact produced by the project. Common values are jar, war (for web applications), and pom.
<name>
A human-readable name for the project.
<description>
A brief description of the project.
Dependencies
<dependencies>
Contains the list of dependencies required by the project. Each dependency is defined within a <dependency> element.
Plugins
<build>
Configures the build process. This section is where you define plugins that extend Maven’s capabilities.
Example:
<plugins>: A list of plugins used in the build process.
<plugin>: Each plugin has a groupId, artifactId, and version, similar to dependencies.
Properties
<properties>: Used to define project properties that can be referenced elsewhere in the POM.
<repositories>: Specifies additional repositories where Maven can find dependencies.
Maven Tutorials
Maven Tutorials on this website can be found at:
For more information on Apache Maven, visit the official website: