0

I am currently going through a Spring and Maven tutorial, and I am unable to add the existing libraries in .m2 folder to my Eclipse project to be used further. When I add dependency of two Spring jar files in tab, two things should happen ideally but it does not happen:

  1. Maven Dependencies library should be created (where all the jars from pom file should be placed)
  2. I still get an error on accessing Spring functionality.

Attached with the post is the screenshot that does not have the Maven Dependencies library in it:

On adding spring libraries with pom file, the Maven Dependencies library is not created in which all the jars from POM file should be placed

I created a Java project and converted it into a Maven project.

kryger
  • 12,906
  • 8
  • 44
  • 65
irshad.ahmad
  • 276
  • 3
  • 9
  • 24
  • Can you show the error? – Oh Chin Boon Oct 05 '15 at 13:04
  • @ Oh Chin Boon : I am unable to attach the image. But this is the error "The import org.springframework. cannot be resolved", basically it is unable to locate the desired jar. – irshad.ahmad Oct 05 '15 at 13:11
  • @Gimby : No, i am not seeing "convert to maven project" option under Configuration option. – irshad.ahmad Oct 05 '15 at 13:12
  • Is there are a "maven" menu option then when you right-click on the project? If yes then Maven support is indeed active. Generally the dependencies don't appear when there is a problem with the pom (although I don't see the familiar red cross on the pom.xml...), can you successfully do a mvn clean install on the command prompt? – Gimby Oct 05 '15 at 13:18
  • Speaking of problems and the maven menu item, if there were problems earlier that you fixed, it might be necessary to force a *maven -> update project* once to get the project to be properly Mavenized. – Gimby Oct 05 '15 at 13:21
  • @Gimby : Yes, i can see the Maven option when i right click on the project. And as per pom, the pom has no errors since there is no cross in the file. mvn clean(yes). mvn install(no) – irshad.ahmad Oct 05 '15 at 13:22
  • I assume you don't have direct Internet access when you write `existing libraries in .m2 folder` Did you downloaded the libs already? If yes, in which folders did you saved them? – hinneLinks Oct 05 '15 at 13:30
  • "mvn install(no) " does that mean the mvn install does not work? If so, then what is the error being produced? – Gimby Oct 05 '15 at 13:38
  • Post your pom.xml in the main post or if you fail to do that, try something like pastebin.com and paste the link here. – We are Borg Oct 05 '15 at 15:34
  • @HinneLinks : The .m2 folder is populated and group id and artifact ids match the path in .m2 folder. So i believe the libraries exist and path to those libraries are correct as well. – irshad.ahmad Oct 06 '15 at 05:46
  • @Gimby : The error said that it needs tools.jar in jre folder, which i further drilled down and found out that it actually *requires jdk's bin path in PATH variable in environment variable*. Thank you Gimby so much for your time, you sowed the right direction. – irshad.ahmad Oct 06 '15 at 05:48
  • @We are Brog : Thank you for giving your time to this problem, but the problem was never with pom file or maven, but with the missing entry in PATH variable for JDK's bin folder. Sounds weird but this was the case. – irshad.ahmad Oct 06 '15 at 05:50
  • Maybe in your `.m2/settings.xml` you have a different path for the local reposiotry (tag `localRepository`)? – hinneLinks Oct 06 '15 at 06:44
  • @irshad.ahmad So in Eclipse you also only had a runtime configured instead of a JDK? If so I would self-answer this question with that fact as that is new to me that this will cause to simply "nothing happening" in a Maven project. EDIT: Oh, I see the question is locked now... Sigh. – Gimby Oct 06 '15 at 07:49
  • @JinneLinks : .m2/settings.xml file has correct path the repository. The problem was with jdk bin's path entry in PATH and it is resolved. Thank you for the time :) – irshad.ahmad Oct 06 '15 at 10:08
  • @Gimby : Eclipse is configured with JDK(other workspace runs fine). – irshad.ahmad Oct 06 '15 at 10:09
  • sad, the duplicate answer did not match the problem that i had and the resolution is different as well. – irshad.ahmad Oct 06 '15 at 10:09

1 Answers1

0

Try to clean build your project. Go to Project-> clean. select your project and select check box says "Start a build immediately". And refresh your project.

And still if it is not working then Right click on your project Go to Maven --> Update Project.

Harshil
  • 69
  • 1
  • 2