Added Maven dependency, Eclipse doesn't see it

做~自己de王妃 提交于 2019-12-23 07:37:09

问题


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:

  • Tried cleaning the project and letting it automatically rebuild.
  • Clean, auto-rebuild, re-start Eclipse.
  • mvn clean followed by mvn install
  • https://stackoverflow.com/a/6913992/91933
  • https://stackoverflow.com/a/12978632/91933
  • https://stackoverflow.com/a/2393810/91933 (although I couldn't get Eclipse to accept $HOME/.m2 as the Maven repository (which it is)).

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)

回答1:


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 



回答2:


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.



来源:https://stackoverflow.com/questions/24483233/added-maven-dependency-eclipse-doesnt-see-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!