1

Trying to solve some my problems and looking at many wise discussions such as:

Maven parent pom vs modules pom,

I came to a conclusion that I do not understand something absolutely basic in all that stuff about POMs.

How can a POM that is a root one, have a parent or even maybe parents?

It seems that maven has special interpretation of what is the parent and what is the root. But I am afraid that all documentation that I have found takes such simple terms for something already known. Sorry, they are not such for me.

Gangnus
  • 24,044
  • 16
  • 90
  • 149

1 Answers1

1

So as to explain a bit about How root POM have Parent I need to take help of example.

Whenever we initialize any project using Spring Boot then we use following parent definition in pom.xml

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.8.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

Now this parent definition facilitate inheritance of common managed dependencies needed to for your application to behave in Spring boot way. These parents have their own pom.xml and those pom mentions common dependencies. Maven central repositories understands these Poms. So this is kind of pom to pom inheritance.

Few of examples of inherited managed dependencies are: 1. Logging using slf4j 2. testing using junit

and so on... and so many..

So here opinionated Spring Boot Project becomes parent project and your maven root pom.xml become beneficiary.

Pramod S. Nikam
  • 4,271
  • 4
  • 38
  • 62