Maven M2_REPO is non modifiable

Problem

Forgot what i did, may be installed m2eclipse plguin, it made the M2_REPO classpath variable is unable to edit. Select Windows -> Preferences -> Java -> Build Path -> Classpath Variables.

Eclipse come with embedded Maven and have this M2_REPO classpath variable default non modifiable also.

Figure – M2_REPO is non modifiable

M2_REPO non modifiable

Solution

To modify the M2_REPO value, you need to change it at Eclipse’s Maven configuration page. Select Windows -> Preferences -> Maven -> User Settings.

Figure – Change it to another Maven repository.

M2_REPO non modifiable

Once above value is updated, it will update the M2_REPO classpath variable automatically.

For Mac OSX Eclipse users
The “preferences” is at menu, Eclipse -> Preferences -> Maven -> User Settings.

mkyong

Founder of Mkyong.com, passionate Java and open-source technologies. If you enjoy my tutorials, consider making a donation to these charities.

27 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Umesh Kumar
12 years ago

Thanks a lot MKYONG….you really explain everything well !!!!

Vishnu Venugopal
3 years ago

Thanks mkyong!!
After maven User settings update, M2_REPO classpath variable is not getting reflected still showing default m2 path.

anyway its working with remapped m2 🙂

Wernbold
6 years ago

Thanks, very nice! You saved my day 😉

STS user
6 years ago

bots comments below…. this does not work

Anantharam AS
8 years ago

thanks this helped

rajesh pal
10 years ago

great !!!!!!! its Working, Thanks

Amy Yang
10 years ago

it seems not working if the user settings.xml uses an environment variable to indicate the repository like ${MYHOME}/.m2/repository

Emiliano Castellanos
10 years ago

it works fine for me, thanks !

Mouammine
11 years ago

HI Mkyong

je te remercie beauoup pour ce tutorial . I received an error when I ran the batch command by CommandLineShareJobRunner

here is the commad that I have executed

C:UserspcDesktopSpringBatchExample4target>java -cp “target/dependency-jars/*:target/spring-batch.jar” org.springframework.batch.core.launch.support.Command

LineJobRunner spring/batch/jobs/job-read-files.xml readJob

Erreur : impossible de trouver ou charger la classe principale org.springframewo

rk.batch.core.launch.support.CommandLineJobRunner

rr
11 years ago

and as always – you just have the answer – my third visit here today…click on the ads here so he can get something in return people !

Mukthiyar Shaik
12 years ago

Thank you MKYONG, This website has gr8 infomation on technologies and problem solving too..

Reeti
12 years ago

I added external maven in eclipse and also add new variable in java->classpath variables. but still mvn is not recognized.. ???

dvai
12 years ago

I don’t know why, but it didn’t work for me. Its showing me the new path under user settings but the variable M2_REPO is still having same old value 🙁
Please help.

Arun
12 years ago
Reply to  dvai

Make sure you have C:/your/local/maven/repository element in your settings.xml

San
10 years ago
Reply to  Arun

Thank you so much for this suggestion, Arun. It saved me a lot of trouble.

Frederik
12 years ago

BUT you’ll have to ‘Restart’ Eclipse before this change is taken into effect…!

Aletha
13 years ago

Just want to say thank you very much, it all works, your steps are easy to follow, I love the way there is more than one way to get things done, you have helped me a lot. Have a nice day!!

Mohit Arora
13 years ago

Perfect answer !!

metaboy
13 years ago

awsome…

Andy
13 years ago

Thanks

uday
13 years ago

Thanks it is useful .

gf
13 years ago

thanks – to the point answer.

dA SAD FSDF
13 years ago

EXCELLENT!!!! THANKS.

Jesse
13 years ago

Yay! (Same issue =])

chandan modi
13 years ago

awsome…

Mohan
13 years ago

Thanks a ton !
Ur post helped to fix the problem finally(had a bad time searchin for right website)
Thanks again

Pavan
13 years ago

That’s cool! Thanks for saving my time..