When rebuilding my project with Maven I sometimes get hundreds of
'unbound classpath variable M2_REPO/etc/..'
in my eclipse errors, most of the time when I rebuild again it goes away but on this occasion its cursed me enough to stick around.
When actually going through the file system, the jars it details that are not there are actually there. Eclipse is just not seeing them for some reason. My m2_repo is correctly referenced in my preferences->java->classpathvariables section and my environmental variables are likewise properly set.
Any ideas for me folks?
If you already did several times STEP 1, go to STEP 2
STEP 1
Try deleting and redefining env vars:
C:/Users/user/.m2/repository
Beside from inside of Eclipse, you can also add the M2_REPO variable from command line using this Maven command:
mvn -Declipse.workspace=<path-to-eclipse-workspace> eclipse:add-maven-repo
STEP 2
If your build path is correctly defined, check Maven settings.xml:
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).
Well, I tried the steps in @Jordi's answer. But those didn't make any difference. And I tried some ritualistic things in eclipse such as:
with no success.
Then strange thing happened when I changed the Java complience level to 1.8 and revert it back to 1.6. It worked! All unbound classpath variable errors are gone now.
Update Project
worked for me :Select the project folder that is giving the error.
Alt + F5
shortcut OR right-click >> Maven >> Update Project
.
Click OK
and let it update.
The errors should disappear after that.
Good Luck
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With