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 !!

Lokesh has written 269 articles

I have 7 Years of rich experience in java technology. This has only increased my hunger to learn more. In this blog, i will be writing on different topics occasionally, and would love to engage in some meaningful serious discussions with you folks.

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

Want to ask any question? Or suggest anything?