Create a multi module Maven archetype

It can be very helpful to dispose of a library of pre-configured projects. Here, we want to create a multi-module project composed of a core (Hibenate Dao) and a web (SpringMVC webapp) module.

<project xmlns="" xmlns:xsi=""


Use a mvn archetype:create-from-project to create the archetype project.
and in target/generated-sources/archetype/ use a mvn install.

In the end, into a new directory, the mvn archetype:generate -DarchetypeCatalog=local will allow you to use the project as a ready-to-code project 🙂

D:\documents\NetBeansProjects>%M2_HOME%\bin\mvn archetype:generate -DarchetypeCa
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] org.apache.maven.plugins: checking for updates from central
[INFO] org.codehaus.mojo: checking for updates from central
[INFO] artifact org.apache.maven.plugins:maven-archetype-plugin: checking for up
dates from central
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO]    task-segment: [archetype:generate] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] Preparing archetype:generate
[INFO] No goals needed for project - skipping
[INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus
[INFO] Setting property: velocimacro.messages.on => 'false'.
[INFO] Setting property: resource.loader => 'classpath'.
[INFO] Setting property: resource.manager.logwhenfound => 'false'.
[INFO] [archetype:generate {execution: default-cli}]
[INFO] Generating project in Interactive mode
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.
Choose archetype:
1: local -> parent-archetype (parent-archetype)
Choose a number:  (1): 1
Define value for groupId: : net.stephou
Define value for artifactId: : springmvc-mvn-webapp
Define value for version:  1.0-SNAPSHOT: :
Define value for package:  net.stephou: :
Confirm properties configuration:
groupId: net.stephou
artifactId: springmvc-mvn-webapp
version: 1.0-SNAPSHOT
package: net.stephou
 Y: : Y
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 minute 15 seconds
[INFO] Finished at: Sun Feb 28 22:11:56 CET 2010
[INFO] Final Memory: 8M/14M
[INFO] ------------------------------------------------------------------------

A new folder named springmvc-mvn-webapp will appear in the selected folder. Just open it in your favourite IDE.

See also :

Create a Maven archetype from an existing project on Eclipse

First, a mvn archetype:create-from-project and a mvn install on the created archetype in target/generated-sources/archetype directory.

A directory, named ${groupId}/${artifactId}-archetype, containing a jar and pom.xml is generated into the repository.

A mvn archetype:crawl -Drepository=/path/to/.m2 is then used to generate the archetypes catalog. The archetype-catalog.xml file is by default generated in .m2/repository (this can be changed while using the parameter -Ddirectory=/path/for/xml)

Finally, in Eclipse, go to Window > Prefences > Maven > Archetypes > Add local catalog, enter the name and directory of this catalog.

When you create a new Maven project on Eclipse, you can select your ${groupId}/${artifactId}-archetype in your catalog freshly named.

More on :