Monday, 30 January 2017

Parent and Child POM.xml


We can maintain parent and child pom.xml files for better and clearer dependency management in larger sized projects.

All the dependencies in the parent pom will be available in child pom by default and child pom dependencies overrides if mismatch happens.

Note : Directory structure has no dependency over parent and child relation of pom files.

Folder structure:
|commonapp
|  -----pom.xml
|springapp
| ------pom.xml

Parent Pom.xml
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.concretepage.app</groupId>
  <artifactId>commonapp</artifactId>
  <version> 1.0-SNAPSHOT</version>
</project>

Child pom.xml
<project>
  <parent>
    <groupId>com.concretepage.app</groupId>
    <artifactId>commonapp</artifactId>
    <version>1.0-SNAPSHOT</version>
    <relativePath>../commonapp/pom.xml</relativePath>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <artifactId>springapp</artifactId>
</project>



No comments:

Post a Comment