Main Tutorials

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.

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
27 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Umesh Kumar
10 years ago

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

Vishnu Venugopal
1 year 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
3 years ago

Thanks, very nice! You saved my day 😉

STS user
4 years ago

bots comments below…. this does not work

Anantharam AS
5 years ago

thanks this helped

rajesh pal
8 years ago

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

Amy Yang
8 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
8 years ago

it works fine for me, thanks !

Mouammine
8 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
9 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
10 years ago

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

Reeti
10 years ago

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

dvai
10 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
9 years ago
Reply to  dvai

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

San
8 years ago
Reply to  Arun

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

Frederik
10 years ago

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

Aletha
10 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
11 years ago

Perfect answer !!

metaboy
11 years ago

awsome…

Andy
11 years ago

Thanks

uday
11 years ago

Thanks it is useful .

gf
11 years ago

thanks – to the point answer.

dA SAD FSDF
11 years ago

EXCELLENT!!!! THANKS.

Jesse
11 years ago

Yay! (Same issue =])

chandan modi
11 years ago

awsome…

Mohan
11 years ago

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

Pavan
11 years ago

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