---
title: "How To Add M2_REPO Classpath Variable To Eclipse IDE"
author: "robert.wei"
date: "2014-04-13T23:49:21Z"
tags: []
categories: ["非技术"]
slug: "how-to-add-m2-repo-classpath-variable-to-eclipse-ide"
draft: false
lastmod: "2014-04-13T23:49:21Z"
id: 2044594
url: "https://robert-wei.iteye.com/blog/2044594"
---

1. Add M2_REPO Manually
Define and add M2_REPO classpath variable manually into Eclipse IDE. Follow below steps :

Eclipse IDE, menu bar
Select Window > Preferences
Select Java > Build Path > Classpath Variables
Click on the new button > defined a new M2_REPO variable and point it to your local Maven repository
Done.

2. Add M2_REPO Automatically – eclipse:configure-workspace
Alternatively, you can define and add M2_REPO via Maven command “eclipse:configure-workspace“.

mvn -Declipse.workspace="your Eclipse Workspace" eclipse:configure-workspace
See an example :

C:\>mvn -Declipse.workspace="C:\Users\mkyong\workspace" eclipse:configure-workspace
 Scanning for projects...
 Searching repository for plugin with prefix: 'eclipse'.
 ------------------------------------------------------------------------
 Building Maven Default Project
    task-segment:  (aggregator-style)
 ------------------------------------------------------------------------
 
 ------------------------------------------------------------------------
 BUILD SUCCESSFUL
 ------------------------------------------------------------------------
 Total time: 1 second
 Finished at: Thu Apr 14 20:45:17 SGT 2011
 Final Memory: 9M/112M
 ------------------------------------------------------------------------
Done.

Verify M2_REPO is Added
Review classpath variable to verify that the M2_REPOis added into Eclipse IDE.