Part 2- Adding dependency jars to multi-module MVN project

This extends Part 1: Creating an empty multi module maven project structure.

maven multi-module project

maven multi-module project

Dependency Management allows you to consolidate and centralize the management of dependency versions without adding dependencies which are inherited by all children. The dependencyManagement control the versions of artifacts used in transitive dependencies.

So, add this to the parent pom.xml file under simple-app-parent/pom.xml.

In your parent pom, in addition “dependencyManagement/dependencies” still you need to add “dependencies” as “dependencyManagement” is there to share the versions across child modules.

Now, if you build the war project with “mvn clean package” or “mvn clean install” you will have

mvn-multi-module-war-3

Now let’s do 2 things in child pom “simple-app-endpoint/pom.xml”:

1) override “commons-collections” artifact version. The parent version is “3.2.1” and the child version is “3.2.1”.
2) let’s give the built war file a version like “simple-app-endpoint-1.0-SNAPSHOT.war” by modifying the “buld/finalName” tag.

mvn-multi-module-war-4


800+ Java Interview Q&As Menu

Learn by categories on the go...
Learn by categories such as FAQs – Core Java, Key Area – Low Latency, Core Java – Java 8, JEE – Microservices, Big Data – NoSQL, Architecture – Distributed, Big Data – Spark, etc. Some posts belong to multiple categories.
Top