Gangnus
Gangnus

Reputation: 24464

POM references a dependency and a parent the same way. How we choose what is what?

I found that syntax of parent and dependency references in POM are practically the same:

<parent>
    <groupId>com.topdesk</groupId>
    <artifactId>tis-parent</artifactId>
    <version>3.4</version>
</parent>

Dependency has the same inner content. Why we choose to put something as parent instead of using dependency?

Upvotes: 1

Views: 42

Answers (1)

J Fabian Meier
J Fabian Meier

Reputation: 35795

These are different concepts. Referencing a parent makes Maven look for a pom from which it inherits (using all the plugin definitions, profiles, declared dependencyManagement etc.), i.e. the parent and your pom are put together as one and executed.

Using a dependency means that Maven looks for a jar (unless you explicitly tell it to look for a pom, which essentially means that it adds all dependencies from that pom as transitive dependencies). This jar is put on the classpath (together with its dependency tree).

Upvotes: 3

Related Questions