Maven Archetype is a Maven project template plug-in. It enables developers to create a new maven project consistently and quickly.
Eclipse IDE comes with nine most commonly used archetypes. Maven hosts about over 600 archetype in the remote catalog. I will show you how to import these archetypes into Eclipse IDE.
In this example, I will demonstrate how to create a new Maven project from a Maven archetype in Eclipse IDE.
2. Technologies Used
The example code in this article was built and run using:
- Java 1.8.101
- Maven 3.3.9
- Eclipse Oxygen
3. Create a Maven Project from an Archetype
3.1 Create a New Web Application Project
Eclipse includes several common archetypes from the internal catalog. In this step, I will demonstrate how to create a Maven project based on
Launch Eclipse IDE. Select
File->New...->Project...->Maven-->Maven Project and click
maven-archetype-webapp” from the archetype grid.
Enter Maven properties: group id, artifact Id, and version. Click
In this step, I will build the generated maven project and deploy it under a tomcat web server. It should include a standard maven project,
index.jsp based on the definition of maven-archetype-webapp.
Open the Eclipse project and verify it.
<html> <body> <h2>Hello World!</h2> </body> </html>
It should automatically build. I can deploy it to a tomcat server. Click here for the detail instructions.
After the tomcat starts, go to
http://localhost:8080/archetype-demo. It should display “Hello World!”
4. Import an Archetype from Maven Remote Catalog
Maven hosts a remote archetype catalog with over 600 commonly used archetypes. Click here to see these archetypes in detail. In this step, I will show you how to import archetypes from a maven remote catalog into Eclipse.
Launch Eclipse IDE, Click
Windows -> Preferences -> Maven -> Archetypes. Click
Add Remote Catalog.
http://repo1.maven.org/maven2/archetype-catalog.xml for catalog files. Enter
Remote Archetype for description.
OK. Now Eclipse has a new remote archetype catalog.
You can create a maven project from any of these archetypes with the same steps as in step 3.
In this article, I showed how to import Maven remote archetypes into Eclipse and how to create a new Maven project from the selected archetype.
Most organizations create their own archetype catalog. In that case, developers need to import them into the Eclipse and follow the same step in step 3 to create a new project.
6. Download the Source Code
This example consists of a Maven project generated from
You can download the full source code of this example here: Apache Maven Eclipse Project Creation Using Archetype Example