问题描述
我将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:
- 尝试清理项目并让其自动重建。
- 清理,自动重建,重新启动Eclipse。
-
mvn clean
后跟mvn install
- (虽然我不能让Eclipse接受$ HOME / .m2作为Maven存储库(它是))。
- Tried cleaning the project and letting it automatically rebuild.
- Clean, auto-rebuild, re-start Eclipse.
mvn clean
followed bymvn 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)
推荐答案
效果最佳,解决所有问题。
The suggestion by @khmarbaise works best and solves all problems.
-
只需删除
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
为我完美无瑕。
以下建议(取自)可能只适用于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):
1. A subdirectory named target
2. A subdirectory named .settings
3. A file named .classpath
4. A file named .project
这篇关于添加了Maven依赖关系,Eclipse没有看到它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!