How To Create Maven Project in Eclipse With Archetype

Getting started with Apache Maven in Eclipse

Maven Basics

Maven automates the steps involved in building a software application like adding the JAR files, compiling code, running unit tests, creating the output jar/war file, etc. This makes the code less error-prone. Maven uses an XML configuration file known as the POM file. Developers need to specify information like the JAR files required by an application, the type of output artifact (jar,war, etc). Maven then uses the instructions in the POM file to build the application.

Eclipse Maven Integration

Most of the recent Eclipse releases already include Maven. So, developers do not need to do anything special to install Maven in Eclipse.  However, some earlier versions of Eclipse do not include Maven, so it needs to be installed explicitly from the Eclipse marketplace. Once Maven is set up with Eclipse, it allows you to easily create a Maven project and use all the Maven features like dependency resolution within Eclipse itself.

Create Maven Project with Archetype in Eclipse

Maven archetype provides a template that can be used to create a particular type of Maven project. If a Maven project is created with an archetype selection, Maven creates the POM file accordingly. Some of the common Maven archetypes are as follows:

  • maven-archetype-quickstart – Can be used to create a basic Maven project
  • maven-archetype-j2ee-simple – Can be used to create a simple j2ee project
  • maven-archetype-webapp – Can be used to create a web application

In order to create a Maven project with a webapp archetype, the following steps need to be followed:

1
Create new artefact of type ‘Other’

blank

On Eclipse main menu, navigate to ‘File > New’ and select ‘Other’

2
Select Maven Project

blank

Select the option ‘Maven Project’ and click Next.

3
Uncheck ‘Create Simple Project

blank

Leave the Create a Simple Project (skip archetype selection) checkbox unchecked. Click Next

4
Use filter ‘maven-archetype-webapp

blank

5
Select maven-archetype-webapp.

blank

6
Input Group Id and Artifact Id

blank

Enter a value for Group Id and Artifact Id. Change version and package if required. Click Finish

7
Verify New Maven project in Eclipse

blank

This creates a Maven project in Eclipse with the Maven directory structure and POM file as follows

8
Finish!

Finish! This POM file can then be modified by adding dependencies and other information as required.


Tushar Sharma
Tushar Sharmahttps://www.automationdojos.com
Hi! This is Tushar, the author of 'Automation Dojos'. A passionate IT professional with a big appetite for learning, I enjoy technical content creation and curation. Hope you are having a good time! Don't forget to subscribe and stay in touch. Wishing you happy learning!

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

RELATED POSTS

How To Convert String To Date in Java

Introduction There are often scenarios in programming, where you will need to convert a date in String format to an actual Date object. For example,...

Format Decimal Numbers Using Pattern

The java.text.DecimalFormat class is used to format numbers using a user specified formatting. This concrete subclass of NumberFormat, allows formatting decimal numbers via predefined...

Convert String to Date Using SimpleDateFormat Class

Sometimes, you may need to convert a String to a java.util.Date object. For this, you need to use the SimpleDateFormat class. You need to...

Setting Max/Min Digits For Decimal Numbers With Java DecimalFormat

The DecimalFormat class offers the following four such methods which can be used to easily set the maximum and/or minimum digits for decimal numbers....

Â

RECENT 'HOW-TO'

How To Install Oh-My-Posh On Windows PowerShell

Oh-My-Posh is a powerful custom prompt engine for any shell that has the ability to adjust the prompt string with a function or variable. It does not...

MORE ON CODEX

FEATURED PROJECTS

SEPA Bulk File Generator and Validator

ADjo LABS PROJECT: SEPA Bulk File Generator and Validator. Supported File Types PAIN008, PAIN001, PACS003 and PACS008. Tested for supporting PAIN.008.001.001 and PAIN.008.001.002 (version 1&2). The XML...

MORE IN THIS CATEGORY

Setting Max/Min Digits For Decimal Numbers With Java DecimalFormat

The DecimalFormat class offers the following four such methods which can be used to easily set the maximum and/or minimum digits for decimal numbers....

How To Concatenate Strings in Java

Introduction In Java, a String is a sequence of characters. There are often programming situations where you will need to concatenate Strings. There are several...

Java Tutorial #7 Part 1 – Classes & Objects

Classes are a very important concept in Java. Java code always needs to be written in a class. In this article, we will be...

Introduction to Apache Maven

1. What is Maven When you write a software application, there are many steps in it like adding the necessary JAR files, compiling the source...

CHECKOUT TUTORIALS

Java Tutorial #1 – Variables and Data Types

Table of Contents Introduction 1. Variables 2. Data Types Primitive Data Types Integer Data Types Decimal Data Types Character Data Types Boolean Data Types Reference...
- Advertisement -spot_img