How to Create a Maven Project in Eclipse #techtarget |Video upload date:  · Duration: PT16M23S  · Language: EN

Quick step by step guide to create a Maven project in Eclipse using m2e configure pom and run builds from the IDE

Ready to let a build tool do the boring work while you pretend you always knew what you were doing This guide shows how to create a Maven project in Eclipse with the m2e plugin edit the pom.xml add dependencies and run builds from the IDE without turning your repository into a jar graveyard

Check that m2e is present in Eclipse

Open the Eclipse marketplace and search for m2e or try a Maven action in the IDE to see if it responds Most modern Eclipse packages include Maven integration so you can skip the install step if Maven options show up in the context menu

Create the Maven project

Use File then New then Other then Maven Project to launch the wizard Pick a workspace that you actually use and not a folder named later regret

Choose an archetype and coordinates

  • For a tiny starter pick maven archetype quickstart or another lightweight archetype
  • Enter groupId and artifactId using a reverse domain pattern to avoid future namespace drama
  • Accept the project structure and finish the wizard so Eclipse can add the Maven nature

Edit the pom.xml

Open pom.xml and paste dependency coordinates from Maven Central to add libraries Eclipse will usually download the jars and update the project classpath so your code compiles without manual jar wrangling

Typical pom additions

  • Dependencies for libraries such as JUnit or your logging framework
  • A maven compiler plugin entry to set source and target levels for Java
  • An optional dependencyManagement section when you need to control versions across modules

Build and run from Eclipse

Right click the project then Run As then Maven build and use the goals field with clean install to build a local artifact Use Run As then Java application to quickly run a main class once compilation succeeds

The IDE will download dependencies into your local repository under .m2 repository and wire them into the Eclipse classpath so you do not have to copy jars by hand

Useful Eclipse Maven tips

  • Use Maven Update Project from the project context menu to refresh dependencies and classpath
  • Open the dependency hierarchy or dependency management view to inspect transitive dependencies and spot version conflicts
  • If a plugin or dependency does not resolve try Force Update of Snapshots from the update dialog or check network and proxy settings

Common pitfalls and how to avoid them

Choosing a bad workspace location makes life harder and moving projects later is a chore Use a clear workspace layout from the start

Forgetting to set the maven compiler plugin leads to cryptic compile errors when Java versions mismatch Add the plugin and set source and target to match your JDK

And remember that Maven manages the lifecycle so use the correct goals for the job clean install for a local build and package for creating artifacts

Follow these steps and Eclipse plus m2e will handle dependency management and the build lifecycle while you get to write code and take the credit

I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!

This is a dedicated watch page for a single video.