Narayana Basetty
Narayana Basetty

Reputation: 141

Java Maven pom.xml - dependencies issue

I have a J2EE web application setup using maven build based project.

i have pom.xml, where i have dependencies for my application.

Let's say my App only needed example hadoop-common.jar, log4j.jar becuase of pom.xml which downloads its dependencies jar.

Process downloads all jars in to .m2/repository - locally. When I bundle war the then WEB-INF/lib has many jars along with hadoop-common.jar, log4j.jar.

How do i ensure only hadoop-common.jar, log4j.jar to be included as part of my war not its dependency in the myWebApp.war

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>it.cvc.pcam_team</groupId>
<artifactId>pcamapplication</artifactId>
<packaging>war</packaging>
<version>1.0.0-SNAPSHOT</version>
<name>PCAMApp Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
   <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-common</artifactId>
        <version>2.4.1</version>
    </dependency>
 </dependencies>

...

Upvotes: 0

Views: 269

Answers (1)

Robin
Robin

Reputation: 63

Are these jars added along with the adoop-common? If hadoop-common is dependent on other jars, these may be added transitively. You can exclude specific jars from being included in that way. https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html

Depending on what you're excluding hadoop-common could stop working though, if you exclude something that's needed for it to run.

Upvotes: 1

Related Questions