What is the difference betweendependencyManagement
anddependencies?
Its need to declare dependencies in child project pom's anyway even if they declared in parent project's pom at <dependencyManagement> section
You cannot have a pom
type project as a simple dependency
in another project. (Well, you can - but it will not do anything useful). There can only be a parent-child
relationship. This is essentially managing dependency through inheritance
.
import
scope for pom
type dependency in <dependencyManagement>
section allows you to achieve the equivalent of multiple inheritance
.
You can only import managed dependencies. This means you can only import other POMs into the dependencyManagement
section of your project's POM. i.e.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>other.pom.group.id</groupId>
<artifactId>other-pom-artifact-id</artifactId>
<version>SNAPSHOT</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
What then happens is that all the dependencies defined in the dependencyManagement
section of the other-pom-artifact-id
are included in your POM's dependencyManagement
section. You can then reference these dependencies in the dependency
section of your POM (and all of its child POMs) without having to include a version
etc.
No comments:
Post a Comment