So here’s the situation, I just checked out new project from SVN (Subversion) and when I open up my Eclipse, there are lots of
Java Build Path Problems. The error says something like this:
Unbound classpath variable: 'M2_REPO/...'
Unbound classpath variable M2_REPO
If you get those errors, it means you haven’t set M2_REPO
variable in your Eclipse.
How to Fix Unbound Classpath Variable Error in Eclipse?
- Open the Eclipse Preferences [
Window - Preferences]
- Go to [
Java - Build Path - Classpath Variables]
New and set its name as
Folder and select your Maven repository folder. For example, my repository folder is
C:/Users/Firman El Hakim/.m2/repository
Add M2_REPO Variable
- Done. Rebuild the Project.
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