This is a basic question, I\'m just not really familiar with maven multi-module structures. Say, I have a web application. And I want to connect some modules to it (some ser
If you have a multi-module project you need a structure like the following which will also be represented by the folder structure as well.
+-- root (pom.xml)
+--- module-1
+--- module-2
+--- module-war
Whereas the root module contains a thing like this:
<project ..>
<groupId>com.test.project</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<modules>
<module>module-1</module>
<module>module-2</module>
<module>module-war</module>
</modules>
</project>
In the module-1 your pom should look like this:
<project ..>
<parent>
<groupId>com.test.project</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>module-1</artifactId>
dependencies for the module
</project>
in module-2 it look more or less the same..and in the war module it looks like:
<project ..>
<parent>
<groupId>com.test.project</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<packaging>war</packaging>
<artifactId>module-war</artifactId>
dependencies for the module
</project>
If you have dependencies between the modules for example module-1 depends on module-2 it looks like the following in module-1:
<project ..>
<parent>
<groupId>com.test.project</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>module-1</artifactId>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>module-2</artifactId>
<version>{project.version}</version>
</dependency>
..other dependencies..
</dependencies>
</project>
To build and package your project you will go to parent folder and do simply a
mvn clean package