amenoire amenoire - 1 year ago 83
Java Question

Can't use classes from different Maven modules

Need to create a multi module maven project which consist of a registration module and main project. The problem is that it's impossible to use classes declared in different modules.

e.g.: I have a

in my parent's src/main/java dir and
in child's src/main/java dir. Right now it's not possible to use neither
nor vice versa.

The project's structure looks like this:

+-- AdminPortal <- parent root
+-- registration <- child root
-- pom.xml <- child pom
-- pom.xml <- parent pom

my AdminPortal POM:



Here's child POM:




How can this problem be solved?

Answer Source

Your parent pom has packaging type pom, this is not jar. This is special aggregator module. All java code should be located in jar modules.

Module with packaging type pom cant generate artifacts like jar, war or ear.

Maven by Example - The Simple Parent Project

The parent project doesn’t create a JAR or a WAR like our previous projects; instead, it is simply a POM that refers to other Maven projects.

To use Classes from one module in other module use maven dependency.

Typical project looks like this:

* administration project (pom)
   * registration (jar)
   * portal (war)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download