添加了Maven依赖关系,Eclipse没有看到它 [英] Added Maven dependency, Eclipse doesn't see it

查看:377
本文介绍了添加了Maven依赖关系,Eclipse没有看到它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将guava 17.0添加到我的pom.xml中,Eclipse自动重建项目。

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

Ran mvn依赖关系:resolve ,maven在解析文件列表中显示 com.google.guava:guava:jar:17.0:compile

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

然而在Eclipse中,我尝试自动完成 com.google.g ,它说没有默认提案。我已经在我的pom.xml中添加了依赖项,运行 mvn依赖关系:resolve 并且Eclipse立即将它们接回来。这个时候有什么不同?

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)).

我可以看到 target /< projname> -1.0-SNAPSHOT / WEB-INF / lib / guava-17.0.jar

我的配置:


  • OS X 10.9.3

  • Maven:3.1.1

  • Eclipse:开普勒2e 1.4)

推荐答案

@ khmarbaise 效果最佳,解决所有问题。

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


  1. 只需删除

  1. Just delete the project from Eclipse.

重新导入为现有Maven项目,并将其指向包含项目 pom.xml的目录文件。

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

让Eclipse的 m2e >

Let Eclipse's m2e plugin handle the rest

为我完美无瑕。

以下建议(取自 https://developers.google.com/appengine/docs/java/webtoolsplatform# maven )可能只适用于GAE项目,但似乎应该普遍适用(我的项目是GAE,所以不能确定):

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):


Maven的根目录下的目录必须
包含以下任何一项:

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 


这篇关于添加了Maven依赖关系,Eclipse没有看到它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆