15

I add guava 17.0 to my pom.xml, Eclipse automatically rebuilds project.

Ran mvn dependency:resolve, maven shows com.google.guava:guava:jar:17.0:compile in the list of resolved files.

However when in Eclipse I try to auto-complete com.google.g, it says "No default proposals". I've added dependencies in my pom.xml before, run mvn dependency:resolve and Eclipse picked them up immediately. What's different this time?

I've tried the following so far:

I can see target/<projname>-1.0-SNAPSHOT/WEB-INF/lib/guava-17.0.jar.

My configuration:

  • OS: OS X 10.9.3
  • Maven: 3.1.1
  • Eclipse: Kepler (with m2e 1.4)
Community
  • 1
  • 1
markvgti
  • 4,321
  • 7
  • 40
  • 62
  • can you see that jar being added in eclipse managed classpath ? – jmj Jun 30 '14 at 05:07
  • 1
    try running the `mvn eclipse:clean` and then the `mvn eclipse:eclipse` command in a seperate command prompt and then refresh the project in eclipse. Most of the times, this works for me. – Rahul Jun 30 '14 at 05:11
  • 1
    Don't use `mvn eclipse:eclipse` use the import of Eclipse and the rest is handled by `m2e` plugin of Eclipse. – khmarbaise Jun 30 '14 at 07:25
  • @khmarbaise You're saying that I should run `mvn eclipse:clean`, remove the project from Eclipse and then re-import it? – markvgti Jul 04 '14 at 05:45

4 Answers4

13

The suggestion by @khmarbaise works best and solves all problems.

  1. Just delete the project from Eclipse.

  2. Re-import as "Existing Maven Projects" and point it towards the directory that contains the project's pom.xml file.

  3. Let Eclipse's m2e plugin handle the rest

Worked flawlessly for me.

The following advice (taken from https://developers.google.com/appengine/docs/java/webtoolsplatform#maven) may only apply to GAE projects, but seems like it should be generally applicable (my project is GAE, so can't be sure):

The directory at the root of the Maven project must not contain any of the following:

1. A subdirectory named target

2. A subdirectory named .settings

3. A file named .classpath

4. A file named .project 
Community
  • 1
  • 1
markvgti
  • 4,321
  • 7
  • 40
  • 62
  • I have all of those folders in my Maven project root folder, yet I can use similar Maven dependencies like apache commons-lang without any problems. Is Guava different in some way? – James Daily Jul 27 '15 at 18:49
  • Maybe this will help someone: The certificate to communicate with my organization's maven artifactory had expired; once I updated it everything worked. – James Daily Jul 27 '15 at 21:34
  • 2
    @JamesDaily I think that advice is only for the first time when importing a maven project into Eclipse. – markvgti Jul 28 '15 at 08:06
  • The root directory does need those files. – robben May 12 '17 at 14:15
  • @markvgti Eclipse didn't like me removing .project! Are you sure about this one? – Paul Morrison Feb 17 '20 at 21:07
  • Hi @PaulMorrison! Can't claim to be an Eclipse expert, but it worked for me. YMMV. Did you exit Eclipse before you did all this? The idea is that the `m2e` plugin will regenerate the project. – markvgti Feb 18 '20 at 04:48
  • Thanks, @markvgti ! That's probably what happened to me! I cleaned out the .m2\repository folder, and the project is now working! – Paul Morrison Feb 19 '20 at 03:11
1

In file pom.xml inside < dependency > seleneium maybe you have defined < scope> test e.g. < scope>test < /scope>.

Removing/deleting this also can solve your problem.

kj007
  • 6,073
  • 4
  • 29
  • 47
0

At first, remove projects as markvgti suggested. I did this three times without success.

My solution was deleting ".project" files and the ".settings" directory in the several projects. Last step was reimporting as "Maven Projects" in eclipse.

kaya
  • 1,626
  • 1
  • 21
  • 27
0

I faced the issue too where my WebDriver and chrome driver was not being recognized even after adding the selenium dependencies. Followed below steps seeing the above comments.

And the issue got resolved. Thanks for the help.

  1. Create a Maven project.
  2. Add Maven dependencies(selenium and testng minimum)
  3. Go to CMD to where your project is.
  4. Run command mvn eclipse:clean
  5. Then run command mvn eclipse:eclipse
  6. Go to eclipse and refresh your project to apply the dependencies and then the jars are added to your project.