Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add maven repository jars to eclipse buildpath?

From eclipse I can see all the necessary jars in maven repositories view. But I have around 100 errors for the missing jar files. So I have set M2_REPO environment variable. I have ran the mvn eclipse:eclipse command from command line. When I run this command an ear package is added to one of subpackages of my project. For example my project name is portal. And sub package is portal_ear. The ear after running mvn eclipse:eclipse command is added to target folder of portal_ear. So my question is as I have the jars already in the repository, how can I add those to the portal buildpath inside eclipse?

Thanks.

like image 250
Sara Avatar asked Jun 10 '12 22:06

Sara


1 Answers

When you're using M2Eclipse, all you need to do is to make sure your Eclipse project is a Maven project. Select the project, click on "Convert > Convert to Maven project" or "Maven > Enable dependency management".

Do not manually add libraries. Also, the M2_REPO library variable is no longer used with m2eclipse, neither is to run the "mvn eclipse:eclipse" command. That is legacy you don't need to do any more.

You can also import your project by using "File > Import > Maven > Existing Maven project" and M2Eclipse will correctly set up the project's build path.

If you have custom Maven settings, such as an Enterprise Repository, you may want to tell M2Eclipse where to find your settings.xml file, if you do not have it in your user home but in the Maven installation (people do this sometimes). Go to "Window > Preferences > Maven > User Settings" and choose the right settings.xml.

like image 101
mhaller Avatar answered Sep 23 '22 14:09

mhaller