Parent POM (Maven)
퇽회 Definition
A Parent POM is a special configuration file in Apache Maven that allows you to share common settings, dependencies, and configurations across multiple projects (modules).
It helps in centralizing project configuration and avoiding duplication.
퇽훹 Why Use Parent POM?
- Avoid repeating the same configurations
- Maintain consistency across projects
- Simplify dependency and plugin management
- Easier maintenance for large projects
퇽훹 Key Features
1. Centralized Dependency Management
Define dependency versions once and reuse in all child projects.
2. Plugin Management
Common plugins (compiler, testing tools) can be configured in one place.
3. Common Properties
Set shared values like Java version, encoding, etc.
퇽훹 Structure of Parent POM
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>parent-project</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<modules>
<module>module1</module>
<module>module2</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.3.0</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
퇽훹 Child POM Configuration
<parent>
<groupId>com.example</groupId>
<artifactId>parent-project</artifactId>
<version>1.0</version>
</parent>
Ⅱ Child projects inherit configurations from the parent.
퇽훹 Advantages
- Reduces duplication
- Ensures consistency
- Easier updates (change once, reflect everywhere)
- Supports multi-module projects
퇽훹 Real-Time Example
In a company project:
- Parent POM defines dependencies and plugins
- Child modules (UI, Backend, API) inherit them
퇽훹 When to Use
- Large enterprise applications
- Multi-module projects
- Projects requiring standardization
