Adding M2_REPO classpath variable in eclipse IDE

Spread the words...Share on Google+3Share on Facebook1Tweet about this on Twitter6Share on LinkedIn2Buffer this pageShare on StumbleUpon0Share on Reddit0

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

Spread the words...Share on Google+3Share on Facebook1Tweet about this on Twitter6Share on LinkedIn2Buffer this pageShare on StumbleUpon0Share on Reddit0

Give me your email address and whenever I write any tutorial or discuss any java concept, you will receive a little email in your inbox.

Join 2,842 other subscribers

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

Leave a Reply