Java 添加了Maven依赖,Eclipse看不到
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24483233/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Added Maven dependency, Eclipse doesn't see it
提问by markvgti
I add guava 17.0 to my pom.xml, Eclipse automatically rebuilds project.
我将 guava 17.0 添加到我的 pom.xml,Eclipse 会自动重建项目。
Ran mvn dependency:resolve, maven shows com.google.guava:guava:jar:17.0:compilein the list of resolved files.
Ran mvn dependency:resolve,maven 显示com.google.guava:guava:jar:17.0:compile在已解析文件列表中。
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:resolveand Eclipse picked them up immediately. What's different this time?
但是,当我在 Eclipse 中尝试自动完成时com.google.g,它显示“没有默认建议”。我之前在我的 pom.xml 中添加了依赖项,运行mvn dependency:resolve和 Eclipse 立即获取它们。这次有什么不同?
I've tried the following so far:
到目前为止,我已经尝试了以下方法:
- Tried cleaning the project and letting it automatically rebuild.
- Clean, auto-rebuild, re-start Eclipse.
mvn cleanfollowed 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)).
- 尝试清理项目并让它自动重建。
- 清理,自动重建,重新启动 Eclipse。
mvn clean其次是mvn install- https://stackoverflow.com/a/6913992/91933
- https://stackoverflow.com/a/12978632/91933
- https://stackoverflow.com/a/2393810/91933(虽然我无法让 Eclipse 接受 $HOME/.m2 作为 Maven 存储库(它是))。
I can see target/<projname>-1.0-SNAPSHOT/WEB-INF/lib/guava-17.0.jar.
我可以看到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)
- 操作系统:OS X 10.9.3
- Maven:3.1.1
- Eclipse:开普勒(使用 m2e 1.4)
采纳答案by markvgti
The suggestion by @khmarbaiseworks best and solves all problems.
@khmarbaise的建议效果最好,可以解决所有问题。
Just delete the project from Eclipse.
Re-import as "Existing Maven Projects" and point it towards the directory that contains the project's
pom.xmlfile.Let Eclipse's
m2eplugin handle the rest
只需从 Eclipse 中删除该项目。
重新导入为“现有 Maven 项目”并将其指向包含项目
pom.xml文件的目录。让 Eclipse 的
m2e插件处理剩下的事情
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):
以下建议(取自https://developers.google.com/appengine/docs/java/webtoolsplatform#maven)可能仅适用于 GAE 项目,但似乎应该普遍适用(我的项目是 GAE,所以可以'不能肯定):
The directory at the root of the Maven project must notcontain 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 项目根目录下不得包含以下任何内容:
1. A subdirectory named target 2. A subdirectory named .settings 3. A file named .classpath 4. A file named .project
回答by Darko Margetic
In file pom.xmlinside < dependency > seleneiummaybe you have defined < scope> teste.g. < scope>test < /scope>.
在pom.xml里面的文件中< dependency > seleneium,您可能已经定义了< scope> test例如< scope>test < /scope>.
Removing/deleting this also can solve your problem.
删除/删除它也可以解决您的问题。

