0

Consider that log4j is a direct dependency of project A and project A is a direct dependency of project B, so log4j is transitive dependency of project B. now when I try to compile project B, It fails with an error saying: "package org.apache.log4j does not exist".

So is there a way to compile project B without mentioning log4j as its direct dependency?

I'm using maven 3.2.5 on Centos platform!

EDIT: I have this code in project A's pom.xml file:

    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>${log4j.version}</version>
    </dependency>

I compiled projec A with following command:

mvn package

and installed the artifact wiht 'mvn install-file'

then I put the following to project B's pom.xml file:

<dependency>
    <groupId>group.id</groupId>
    <artifactId>A</artifactId>
    <version>version of A</version>
</dependency>
ayyoob imani
  • 639
  • 7
  • 16
  • 1
    You should not need to declare it explicitly if it is a transitive dependency. Please show the relevant parts of the pom files. – davidxxx Jun 18 '17 at 06:15
  • 1
    If you directly use it, it is good practice to also directly declare it as a dependency (even you also get it via a transitive dependency). This is to avoid surprises if your transitive import gets broken by an unrelated version upgrade. – Henry Jun 18 '17 at 07:37
  • Refer to https://stackoverflow.com/questions/22848165/resolving-transitive-dependency?rq=1 – Hardy Feng Jun 18 '17 at 09:43

0 Answers0