Adding M2_REPO classpath variable in eclipse IDE

We know that what is use maven and how to use it from command prompt. Maven dependencies can be read from eclipse IDE also which maven exposes through M2_REPO classpath variable which points to maven’s local repository. This class variable must be added to eclipse ‘s class path variable on build path before using maven’s dependencies. Lets see how to do this:

Step 1) Go to menu Windows > Preferences

eclipse-preferences

Step 2) Navigate to Java > Build path > Classpath Variables

classpath_variables_for_projects

Step 3) Define new classpath variable M2_REPO and point it to local maven repository

add_maven_repository

Step 4) Verify that variable has been added

m2_repo_variable_added

Happy Learning !!

6 thoughts on “Adding M2_REPO classpath variable in eclipse IDE”

  1. changed facet correctly, but to create web application from scratch mvn archetype:generate
    is stopping at number 242 :242 which creates, not a simple quick start web project but plugin project.
    which does not takes dependencies in pom file .
    so why mvn behavior is correct ?as it has so many options up till 710 , so what do ?

  2. yes I have added the repository but demoWebApplication gives folloing error
    when I changed java compiler from 1.7 to 1.6 ,even for java 1.7 this error was there
    Description Resource Path Location Type

    Java compiler level does not match the version of the installed Java project facet. demoWebApplication Unknown Faceted Project Problem (Java Version Mismatch)

    and when I create myfirstServlet and try to run it ,it gives
    HTTP 404 error-requested re source not available

    Pl give the remedy

Note:- In comment box, please put your code inside [java] ... [/java] OR [xml] ... [/xml] tags otherwise it may not appear as intended.

Leave a Reply

Your email address will not be published. Required fields are marked *


+ 4 = nine

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>