Yesterday for first time I installed m2eclipse plugin and all of a sudden projects failed to compile. I was using Maven for quite long time hence adding all library dependencies for a project using a variable named M2_REPO, which was pointing towards a location where Maven downloaded jars were stored. After installation of m2eclipse plugin Eclipse was not able to resolve the absolute path of the jars in classpath.
The value of the M2_REPO variable was changed itself to some path other than what I configured. When I tried to fix that, to my surprise I can't edit it any longer. It was marked with this text "M2_REPO (non modifiable)". After poking here and there for a while I come to know that m2eclipse picks the value of M2_REPO variable from $MAVEN_HOME/conf/settings.xml (MAVEN_HOME is the currently selected Maven installation) file using <localRepository> element-
<localRepository>PATH_TO_REPOSITORY</localRepository>If nothing is specifed in settings.xml then ${user.home}/.m2 directory becomes the value of M2_REPO variable.
20 Comments:
Thanks for writing about this, I have the exact same problem. Are you saying that if my $MAVEN_HOME/conf/settings.xml has a path specified under this should solve the issue? It's not working for me. my settings.xml is pointing to my correct local repo location but still in eclipse, M2_REPO is pointing to the default location. Please let me know if I'm missing any thing. Thanks, Lior
Can you please check if same Maven installation is currently activated in Eclipse for which you are changing the 'conf/settings.xml'. The currently activated maven can be checked from 'Preferences -> Maven'.
Thanks,
Vinod
I had the same issue.For fixing it you have to add repository informtaion to settings.xml present in your {userprofile}/.m2/settings.xml and restart eclipse
Thanks for this, saved my time.
Probably you all missed one benefit of it. that is, you can create a .classpath file automatically and you do not have to set build path properties for each dependent class.
I stop using it because, it was not picking my env variable.
Another way of generating .classpath is to use mvn eclipse:eclipse command and now i do not set them using project build path in properties.
seriously provided gud insight into M2_REPO variable.. nice post thanks.
After I changed path of setting.xml in
Preferences-->Maven--User Settings
my problem was solved.
Thanks.
~GD
Thanks a lot, you can change your maven setting with Eclipse :
Window/Preferences/Maven/User settings
THANKS MAN YOU RALLY HELPED ME
Thanks for the information, it helped me.
Thanks for the information, it saved me a time.
I've been wasting too much time around eclipse.org before I reached your post... you really saved my time
Many thanks Vinod!
This one is what i was really looking for:
Window/Preferences/Maven/User settings
Thanks for the one posted it. It really helped me.
The suggestion given by anonymous about the 'Preferences-->Maven--User Settings' is easy and it worked. Thanks anonymous.
Thank you for blogging this. Saved a lot of time.
Thanks!
Changing the path of setting.xml in Preferences-->Maven--User Settings my problem is solved.
Thanks very much
The settings.xml was stopped being referenced since I installed sonar and emma plugins. Seems it does maven plugin installation as well by default. As the previous post suggested changing Maven -> User settings in prefrences fixed the issue for me.
Thanks a lot. After finding a lot I got this solution.
Post a Comment