I have 2 projects testing.parent
and testing.child
.
The project structure is as below:
Their individual poms are as below:
testing.parent
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>testing.group</groupId>
<artifactId>testing.parent</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>testing.parent</name>
<url>http://maven.apache.org</url>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies>
</dependencyManagement>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
testing.child
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>testing.group</groupId>
<artifactId>testing.child</artifactId>
<version>1.1</version>
<packaging>jar</packaging>
<name>testing.child</name>
<url>http://maven.apache.org</url>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>testing.group</groupId>
<artifactId>testing.parent</artifactId>
<version>1.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
In order to test the dependency management
I tried to import
the log4j
jar to child
project but still the jar is not available in the child project. Is this the correct way to import the jars?
Yes, include the log4j in the
dependency
section of the childpom.xml
.Also, make sure to refer the
parent
from the child as well, include the following in childpom.xml
for that:ensuring the similar reference in the parent
pom.xml
as