POM File
About
Sample POM File
<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
https://maven.apache.org/xsd/maven-4.0.0.xsd">
<!-- ===== Model Version ===== -->
<modelVersion>4.0.0</modelVersion>
<!-- ===== Project Coordinates ===== -->
<groupId>com.example</groupId>
<artifactId>sample-app</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<!-- ===== Project Metadata ===== -->
<name>Sample Maven Application</name>
<description>An example project demonstrating all POM sections</description>
<url>https://example.com/sample-app</url>
<!-- ===== Parent POM ===== -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.1</version>
<relativePath/> <!-- Look up parent from repository -->
</parent>
<!-- ===== Properties ===== -->
<properties>
<java.version>17</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format>
</properties>
<!-- ===== Dependency Management ===== -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.15.0</version>
</dependency>
</dependencies>
</dependencyManagement>
<!-- ===== Dependencies ===== -->
<dependencies>
<!-- Spring Boot Web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- Testing -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<!-- ===== Build Configuration ===== -->
<build>
<finalName>${project.artifactId}-${project.version}</finalName>
<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<!-- Plugins -->
<plugins>
<!-- Compiler Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<!-- Surefire Plugin (Unit Testing) -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<skipTests>false</skipTests>
</configuration>
</plugin>
<!-- JAR Plugin (Custom Manifest) -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
<mainClass>com.example.MainApplication</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<!-- ===== Repositories ===== -->
<repositories>
<repository>
<id>central</id>
<name>Maven Central Repository</name>
<url>https://repo1.maven.org/maven2/</url>
</repository>
</repositories>
<!-- ===== Plugin Repositories ===== -->
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Maven Central Plugins</name>
<url>https://repo1.maven.org/maven2/</url>
</pluginRepository>
</pluginRepositories>
<!-- ===== Profiles ===== -->
<profiles>
<!-- Development Profile -->
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<maven.compiler.debug>true</maven.compiler.debug>
</properties>
</profile>
<!-- Production Profile -->
<profile>
<id>prod</id>
<properties>
<maven.compiler.debug>false</maven.compiler.debug>
</properties>
</profile>
</profiles>
<!-- ===== Modules (Multi-module projects) ===== -->
<modules>
<module>service-module</module>
<module>web-module</module>
</modules>
</project>The <project> Root Element
<project> Root ElementA. The xmlns Attribute
xmlns AttributeB. The xmlns:xsi Attribute
xmlns:xsi AttributeC. The xsi:schemaLocation Attribute
xsi:schemaLocation AttributeD. Closing the <project> Tag
<project> TagE. Why This Section Matters ?
The <modelVersion> Element
<modelVersion> ElementA. Purpose
B. Current Value
C. Historical Context
D. What Happens if We Change It ?
E. Best Practice
Project Coordinates
A. <groupId>
<groupId>B. <artifactId>
<artifactId>C. <version>
<version>D. <packaging>
<packaging>E. How Maven Uses GAV ?
F. Best Practices
Project Metadata
A. <name>
<name>B. <description>
<description>C. <url>
<url>D. Why Metadata Matters ?
E. Best Practices
The <parent> Section
<parent> SectionA. Purpose
B. Structure
C. How Inheritance Works ?
D. Real-World Examples
E. Inheritance vs. Aggregation
F. Best Practices
The <properties> Section
<properties> SectionA. Purpose
B. How Properties Work ?
C. Common Use Cases
D. Built-In Maven Properties
E. CLI-Defined Properties
F. Best Practices
The <dependencyManagement> Section
<dependencyManagement> SectionA. Purpose
B. How It Works ?
C. Benefits
D. Typical Uses
E. Best Practices
The <dependencies> Section
<dependencies> SectionA. Purpose
B. Key Elements
C. Dependency Scopes
Scope
Available In
Typical Use Case
D. Transitive Dependencies
E. Best Practices
The <build> Section
<build> SectionA. Purpose
B. Key Elements
C. Commonly Used Plugins
D. Advanced Build Customization
E. Best Practices
The <profiles> Section
<profiles> SectionA. Purpose
B. Key Elements
C. How Profiles Work
D. Typical Use Cases
E. Best Practices
The <repositories> Section
<repositories> SectionA. Purpose
B. Key Elements
C. How Maven Resolves Dependencies
D. Best Practices
The <pluginRepositories> Section
<pluginRepositories> SectionA. Purpose
B. Key Elements
C. Difference from <repositories>
<repositories>For Dependencies
For Plugins
D. Best Practices
The <distributionManagement> Section
<distributionManagement> SectionA. Purpose
B. Key Elements
C. Authentication
D. How It Works ?
E. Best Practices
The <reporting> Section
<reporting> SectionA. Purpose
B. Key Elements
C. Common Reporting Plugins
D. Best Practices
Project Metadata Sections
A. <licenses>
<licenses>B. <developers>
<developers>C. <contributors>
<contributors>D. <scm> (Source Control Management)
<scm> (Source Control Management)E. <issueManagement>
<issueManagement>F. <ciManagement>
<ciManagement>Best Practices
Complete Example of pom.xml with All Sections
pom.xml with All SectionsLast updated