I am new in using maven and jenkins. I am trying to inherit the dependencies from parent pom to child pom it shows the following errors:
[ERROR] COMPILATION
Below is the example of how you should use the parent and child poms.
The parent pom is as follows:
.....
4.0.0
group1
group1-artifact
1.0.1
pom
child1
// add more childs here
org.slf4j
slf4j-simple
1.7.21
org.abc
xyz
1.0.0
.......
If you specify a dependency in the dependencyManagement
tag, it simply means that you are making this jar available for the child pom. It would NOT actually download the jar at this point. The child pom will have to provide the groupId
and the artifactId
explicitly to download and use the jar to compile its classes. Note: you don't have to include the version of the dependency in the child poms.
The child pom will be as follows:
.....
4.0.0
// this is how you will inherit from parent pom
group1
group1-artifact
1.0.1
child1
org.slf4j
slf4j-simple
runtime
// no version needed as it would inherit from the parent pom
org.abc
xyz
// no version needed as it would inherit from the parent pom
.......
It is a good practice to put dependencies common to all the childs in the dependencyManagement
tag of the parent pom. This way you can manage the versions of these dependencies from one single place.