Importing maven project into eclipse - Maven Tutorial

If you want to import existing maven project into eclipse. There are  2 ways to do it:

1) Install Eclipse m2e plugin from eclipse.

2) Through running from the command line using  mvn eclipse:eclipse command

METHOD 1:  Eclipse m2e plugin

The m2eclipse plugin is one of the Eclipse plugins for Maven. It’s actually the first and most mature of the projects aimed at integrating Maven within the Eclipse IDE.

I find the m2eclipse plugin to be more useful. This provides nice tools like the POM editor and creating a Maven project from within Eclipse.

The following simpler set of steps Importing maven project into eclipse(First install m2eclipse plugin):

  1. Open Eclipse
  2. Click File > Import
  3. Type Maven in the search box under Select an import source:
  4. Select Existing Maven Projects
  5. Click Next
  6. Click Browse and select the folder that is the root of the Maven project (probably contains the pom.xml file)
  7. Click Next
  8. Click Finish

Method 2: using  mvn eclipse: eclipse command:

Note: This plugin is retired. It is no longer maintained. but you can use. NOT RECOMMEND.

This inconsistency problem is long identified with the Eclipse plugin for Maven.If you use the Eclipse IDE for executing Maven commands, It will not work exactly the way that Maven works with the command line. So what most developers do is, run the maven commands from the command line and then execute

mvn eclipse:eclipse

to update eclipse project. After that, you go back to Eclipse IDE and refresh your project. then your project will be updated as per the changes are done via command line.

It is also recommended to update your pom.xml with the following configuration:

<build>    <plugins>        <plugin>            <groupId>org.apache.maven.plugins</groupId>            <artifactId>maven-compiler-plugin</artifactId>            <version>3.5.1</version>            <configuration>                <source>1.8</source>                <target>1.8</target>            </configuration>        </plugin>    </plugins></build>