Question: I have a few questions corresponding to this. 

1. What is M2\_REPO?
2. What does this command do?

`mvn -Declipse.workspace=<your_workspace_location> eclipse:add-maven-repo`
3. Why do we need to do the above?

Answer: 
Go to Windows-> Preference -> Java ->Build Path -> Classpath Variables -> New and add the following ;

Name = M2\_REPO (or what ever name you gave for your Maven repository)
Path = C:\Users\Administrator.m2\repository (Mine is saved here)
No, you don't want all your maven artifacts strewn all over the Libraries folder in eclipse project/package explorer.

You want all the maven artifacts wrapped nicely under one subfolder of

> 
> Java Resources > Libraries > Maven Dependencies
> 
> 
> 

just like in the gd'old days.

After you done everything suggested in the rest of the answers, and all you get is still having all your maven artefacts strewn over the top level of the pkg/prj explorer's top level listing, the reason is because you have just upgraded to the latest and greatest Eclipse version, and the m2eclipse plugin version you have has not raced uptodate with that Eclipse version.

You **ALSO don't want** to run mvn eclipse:eclipse or eclipse:config.. everytime you add new maven dependencies. That simply goes against what maven stands for.

### Work around

While m2eclipse is groping around in the dark in your spanking new eclipse version, 

1. Save your current .classpath.
2. replace your eclipse .classpath with the POME.C (plain old maven eclipse .classpath):
<http://code.google.com/p/synthfuljava/source/browse/apps/durian/.classpath> .
3. Remember to change the java version to yours.
4. Remember to add back all your custom non-maven paths, found in your orig .classpath.
5. Now, be a good citizen and go file an m2eclipse bug (if I haven't yet) for this eclipse version, telling them the m2eclipse is not constructing the good'ol POME.C, explaining how lovely and convenient that POME.C is .

But since googlecode is going away this august (that's a pain, google), here is the body of the file.

```
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
  <classpathentry kind="src" output="target/classes" path="src/main/java">
    <attributes>
      <attribute name="optional" value="true"/>
      <attribute name="maven.pomderived" value="true"/>
    </attributes>
  </classpathentry>
  <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
    <attributes>
      <attribute name="maven.pomderived" value="true"/>
    </attributes>
  </classpathentry>
  <classpathentry kind="src" output="target/test-classes" path="src/test/java">
    <attributes>
      <attribute name="optional" value="true"/>
      <attribute name="maven.pomderived" value="true"/>
    </attributes>
  </classpathentry>
  <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
    <attributes>
      <attribute name="maven.pomderived" value="true"/>
      <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
    </attributes>
  </classpathentry>
  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
    <attributes>
      <attribute name="maven.pomderived" value="true"/>
    </attributes>
  </classpathentry>
  <classpathentry kind="output" path="target/classes"/>
</classpath>

```