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.

27 comments on “Maven M2_REPO is non modifiable

  1. 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 🙂

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

    Reply
  3. 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

    Reply
  4. 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 !

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

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

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

    Reply
  8. 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.

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

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

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

    Reply
  10. 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!!

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

    Reply

Leave a Comment

Your email address will not be published. Required fields are marked *