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 the Author

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

Comments

Leave a Reply

avatar
newest oldest most voted
rajesh pal
Guest
rajesh pal

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

Amy Yang
Guest
Amy Yang

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

Emiliano Castellanos
Guest
Emiliano Castellanos

it works fine for me, thanks !

Mouammine
Guest
Mouammine

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
Guest
rr

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
Guest
Mukthiyar Shaik

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

Reeti
Guest
Reeti

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

dvai
Guest
dvai

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
Guest
Arun

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

San
Guest
San

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

Frederik
Guest
Frederik

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

Aletha
Guest
Aletha

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
Guest
Mohit Arora

Perfect answer !!

metaboy
Guest
metaboy

awsome…

Andy
Guest
Andy

Thanks

uday
Guest
uday

Thanks it is useful .

gf
Guest
gf

thanks – to the point answer.

dA SAD FSDF
Guest
dA SAD FSDF

EXCELLENT!!!! THANKS.

Jesse
Guest
Jesse

Yay! (Same issue =])

chandan modi
Guest
chandan modi

awsome…

Mohan
Guest
Mohan

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

Pavan
Guest
Pavan

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

Umesh Kumar
Guest
Umesh Kumar

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

Anantharam AS
Guest
Anantharam AS

thanks this helped