Software Development

How to create Maven project in Eclipse

Background

This article demonstrates how create a Maven project in Eclipse.

[wp_ad_camp_3]

Software Environment

  • Windows 7 Professional SP1
  • Java 1.7 (1.7.0_67 – Windows x86)
  • Eclipse Kepler
  • Dependecy Testing
    • Apache Commons Lang 3 (3.3.2)
    • Apache Commons IO (2.4)

Create Maven Project

1. Go to New -> Others…

maven-eclipse-001_wm

 

2. Choose Maven Project under Maven

maven-eclipse-002_wm

[wp_ad_camp_2]

3. Click “Create a simple project (skip archetype selection)”

maven-eclipse-003_wm

 

4. Enter text for Group Id, Artifact Id, and Name. Select the type of packaging too.

NOTE: For this demo, please use jar instead of war packaging.

maven-eclipse-004_mw

 

5. The Maven project thus far

maven-eclipse-005_wm

 

6. Let’s try including two libraries into our project – Apache commons lang and IO. Copy and paste the dependency configurations into your pom.xml file

maven-eclipse-006_mw

 

maven-eclipse-008_mw

 

7. Your original pom.xml file

maven-eclipse-007_mw

[wp_ad_camp_1]

8. Your updated pom.xml maven-eclipse-009_mw

 

9. Let Maven download the jar files into your local Maven repository and include in your project in Eclipse

maven-eclipse-010_mw

 

10. Output of Maven Intall command

maven-eclipse-011_mw

[wp_ad_camp_4]

11. Create a sample class that uses any of the jar files

maven-eclipse-012_mw

Sample Codes

maven-eclipse-013_wm

[wp_ad_camp_5]

Loading

Got comments or suggestions? We disabled the comments on this site to fight off spammers, but you can still contact us via our Facebook page!.


You Might Also Like