Step by Step guide – Convert to Maven Project in Eclipse

Post moved to:

http://srinichekuri.com/2016/01/15/step-by-step-guide-convert-to-maven-project-in-eclipse/

**********************************************************************

This post is for step by step guide to convert a single project to Maven project in Eclipse. I recommend going through these links before you read any further.

Step 1: Maven Plugin for Eclipse

First you should make sure that you have Maven Plugin installed in your Eclipse. I am using Eclipse Mars for this demo and this version comes with Maven Plugin. If you are using Eclipse doesn’t have this built in feature then try to install a Maven Plugin. I recommend M2Eclipse Plugin.

Step 2: Convert Java/J2ee Project to Maven Project

Right click on Java Eclipse and select Configure -> Convert to Maven Project.

convert_to_Maven_Project_Eclipse

A popup up that will show build parameters that will be published in pom.xml will be shown.

convert_to_Maven_Project_Eclipse_1

Step 3: Add dependencies to pom.xml

Open pom.xml and Click on Dependencies tab.

Lets try to add log4j.jar as a dependency in pom.xml.

convert_to_Maven_Project_Eclipse_3

convert_to_Maven_Project_Eclipse_4

Step 4: Run Maven Build

Run Maven build by right clicking on pom.xml and selecting Run As -> Maven install.

convert_to_Maven_Project_Eclipse_5

Step 5: Verify Build

You will see that folder is created with naming convention <artifactId>-<version> in build folder. Also you will see that all dependencies are saved to build/<artifactId>-<version>/WEB-INF/lib folder. Also you will see all dependecies are placed in build path under Maven Dependencies.

convert_to_Maven_Project_Eclipse_6

 

convert_to_Maven_Project_Eclipse_7

Multiple dependencies can be added in similar fashion.