Maven – How to add M2_REPO classpath variable to Eclipse

New version of Eclipse like Photon or Eclipse IDE 2019-06 has M2_REPO classpath variable after integrating maven plugins (m2eclipse) with Eclipse IDE, M2_REPO classpath variable gets added –> pointing to default locations (for example c:\Users\\.m2\repository) and this variable is non-modifiable. However, if we are using older version of Eclipse, then we need to add M2_REPO manually to Eclipse.

Steps to add M2_REPO

  1. Open Eclipse IDE, select Window ->Preferences ->Java ->Classpath Variables

2. Click on New Button. Add below mentioned information:-

Name – M2_REPO

Path – Path where M2 file places in your system

Eg – C:\Users\SingVi04\.m2\repository

Note:- I have already added M2_REPO, so we can see an error message – Variable name already exists.

3. Verify that M2_REPO add – You can check new Classpath variable M2_REPO is added under BuildPath ->Classpath Variables

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s