Right now I usually find a pom.xml
file on the web that has a pom
packaging and copy and paste it to create my parent project. Then I used to run <
Consider a parent project bookmarks and 3 sub modules rest, security and model, referring to Spring docs. It doesn't have the dependencies as in the Spring doc, just the basic setup from multi-module point of view.
To create a parent maven project in non-interactive mode/ batch mode
mvn archetype:generate \
-DarchetypeGroupId=org.codehaus.mojo.archetypes \
-DarchetypeArtifactId=pom-root \
-DarchetypeVersion=RELEASE \
-DgroupId=bookmarks \
-DartifactId=bookmarks \
-Dversion=0.0.1-SNAPSHOT \
-DinteractiveMode=false
To create sub modules in non interactive mode/ batch mode.
cd into your newly created root dir. Referring to answer by @Chris.H
-Dpackage is the package structure. Here it is bookmarks. If not specified then it will consider the artifactId as default package
mvn archetype:generate \
-DarchetypeGroupId=org.apache.maven.archetypes \
-DarchetypeArtifactId=maven-archetype-quickstart \
-DarchetypeVersion=RELEASE \
-DgroupId=model \
-DartifactId=model \
-Dversion=0.0.1-SNAPSHOT \
-Dpackage=bookmarks \
-DinteractiveMode=false
To create a new module in eclipse goto File->new->other->maven->maven module, this shows up immediately in eclipse workspace package explorer.
Or from cli, cd inside parent folder, here bookmarks and run the following, it will create the project and then you have to import into eclipse as a maven project, or can work from parent, here bookmarks project
mvn archetype:generate \
-DarchetypeGroupId=org.apache.maven.archetypes \
-DarchetypeArtifactId=maven-archetype-quickstart \
-DarchetypeVersion=RELEASE \
-DgroupId=security \
-DartifactId=security \
-Dversion=0.0.1-SNAPSHOT \
-Dpackage=bookmarks \
-DinteractiveMode=false
Here is a screencast on how you could do it with Intellij Idea. First, start a new project (File -> New Project), choose 'Maven Module':
Type in a name, click next, don't change anything else in the following steps, click finish.
Now in your pom.xml
type <packaging>
and enable auto-updates:
Type in modules:
Place your cursor at m1
and press Alt+Enter.
Module m1
will be automatically added to your project. Now you can do Alt+Enter for m2
and that's it.
You can also start by adding pom.xml
for an existing module of your project: right click on it in the project tree, 'Add Framework Support...', choose 'Maven'. This will create a pom.xml
.