This project has a parent module along with two child modules, one child that depending on the other child. And I wanted the example to be as simple as possible, not even a “Hello World” web application here — just one module that references a class from it’s sibling module.
In order for “dao-mp” to access “utilities-mp”, a dependency on “utilities-mp” must be included.
Sample Project Overview
my.project Maven project (parent pom.xml)utilities Maven sub-module (child 1)
dao Maven sub-module (child 2; depends on child 1)
unit test to verify
- dao-mp sub-module can access utilities-mp sub-module resources
- project JAR files are not installed into the local repository
Util class (part of utilities-mp)
Dao class (part of dao-mp)
The results of running any of these commands should result in showing what's in the reactor and the status of running the tests.
mvn clean package
mvn clean verify
mvn clean test
...
Check to see if any jar files were created in the project.
find . -name "*.jar"
./dao-mp/target/dao-mp-0.0.1-SNAPSHOT.jar
./utilities-mp/target/utilities-mp-0.0.1-SNAPSHOT.jar
mvn compile
find . -name "*.jar"
$
Without including the "compile" phase explicitly, "dependency:tree" will automatically install jars to the local repository. To get the best of both worlds,...
mvn compile dependency:tree
Another quick check to verify no jar files were created
find . -name "*.jar"
$
Mission accomplished! The project can be downloaded to save you some time.