Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

eclipse project not importing the jar packages in local Maven repository

Tags:

eclipse

maven

jar

I am facing a problem in setting my eclipse project. The problem is whenever I am creating a new project and import the code.Eclipse is not resolving the packages which are present in the jar files which are present in the C;/..../user/.m2/repository.

Hence it's giving a lot of compilation errors until I add all the required jar files manually in the build-path by going to "Add External Jars"

I saw that M2_REPO is present in my Eclipse classpath.But still it is not resolving the packages. Please suggest how this problem can be resolved.

Gaurav

like image 603
code4fun Avatar asked Jun 10 '11 15:06

code4fun


2 Answers

I've been having a similar error in Eclipse on OSX. In Eclipse on the Mac, there is no "Maven" entry when you right-click on a project in the explorer.

However!

I just discovered that if I right click and then click "Validate", it suddenly magically resolves all the dependencies. No idea why, but maybe this will help.

like image 88
rogueleaderr Avatar answered Sep 28 '22 15:09

rogueleaderr


I've had this issue on Eclipse Kepler EE which comes prebuilt with m2e, I finally got it working by doing the following on each project:

  • Right click on the Project
  • Select Properties
  • Select Maven
  • Uncheck the option that says: Resolve Dependencies from Workspace projects

It should pop up with a box that says Maven setting has changed. Do you want to update project configuration. Click Yes to this.

To confirm:

  • Right click on the project
  • Select Properties
  • Select Java Build Path
  • Check the Libraries tab under Maven dependencies that all the jar you expected are now there.
like image 31
CheeseFerret Avatar answered Sep 28 '22 16:09

CheeseFerret