Issue in adding M2_REPO variable in eclipse

eclipse, java, maven

Solution

Check for settings.xml in

Window --> Preferences --> Maven ---> User Settings

If not, set it there and change localRepository path in settings tag inside settings.xml. Normally you will find settings.xml in .m2 folder under the user folder (for eg. C:\Documents and Settings\userName.m2).

Problem

I am adding M2_REPO variable in eclipse using `Window --> Preferences --> Java --> Build Path --> Classpath Variables --> New -->` and then providing name as M2_REPO and selecting maven repository folder, then I see this variable getting added in the Classpath variables list. Then I click OK button. After that, if again I see the above Classpath variables, then i don't find the M2_REPO variable there, due to which I am getting `Unbound classpath variable: M2_REPO/....jar` error in my project. Can someone please help.

Original source