Maven Eclipse IDE - Maven

What is Eclipse IDE?

Eclipse includes an important plugin m2eclipse to integrate with Maven and Eclipse together.
Here are some of features of m2eclipse are listed below −
  • To run Maven goals from Eclipse.
  • To view the output of Maven commands inside the Eclipse, using its own console.
  • To update maven dependencies with IDE.
  • To Launch Maven builds from within Eclipse.
  • Performs the dependency management for Eclipse build path based on Maven's pom.xml.
  • To resolve the Maven dependencies from the Eclipse workspace without installing to local Maven repository (requires dependency project be in same workspace).
  • Downloads automatically the required dependencies and sources from the remote Maven repositories.
  • To provide wizards for creating new Maven projects, pom.xml and to enable Maven support on existing projects
  • To provide quick search for dependencies in remote Maven repositories.

Installing m2eclipse plugin

Use one of the following links to install m2eclipse −
Eclipse URL
Eclipse 3.5 (Gallileo)

Installing m2eclipse in Eclipse 3.5 (Gallileo)

Eclipse 3.6 (Helios)

Installing m2eclipse in Eclipse 3.6 (Helios)

Following example will help you to leverage benefits of integrating Eclipse and maven.

Import a maven project in Eclipse

  • Open Eclipse.
  • Select File > Import > option.
  • Select Maven Projects Option. Click on Next Button.

import_project

  • Select Project location, where a project was created using Maven. We've created a Java Project consumer Banking in the previous chapters. Go to ‘Creating Java Project’ chapter, to see how to create a project using Maven.
  • Click Finish Button.
import_project2
Now, you can see the maven project in eclipse.
eclipse_project_structure
Now, have a look at consumer Banking project properties. You can see that Eclipse has added Maven dependencies to java build path.
java_build_path2
Now, it is time to build this project using maven capability of eclipse.
  • Right Click on consumerBanking project to open context menu.
  • Select Run as option.
  • Then maven package option.
Maven will start building the project. Here’s the output in Eclipse Console as follows –
Now, right click on App.java. Select Run As option. Then select Java Application.
run_maven_build
Here’s the output as follows –

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Maven Topics