Eclipse 无法识别现有已解析的 Maven 依赖项
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14807869/
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
Eclipse does not recognize existing resolved Maven dependencies
提问by mico
I have m2 plugin in Ecplipse 3.8.0 and a project that has maven dependencies inside. Local .m2 folder has the correct version of the dependency, pom.xml looks correctly but Dependencies tab when opening the pom.xml in Eclipse tells "Failed to read artifact descriptor.." error. Also I get missing artifact error on the Problems section on Eclipse.
我在 Ecplipse 3.8.0 中有 m2 插件和一个内部有 maven 依赖项的项目。本地 .m2 文件夹具有正确版本的依赖项,pom.xml 看起来正确,但在 Eclipse 中打开 pom.xml 时依赖项选项卡告诉“无法读取工件描述符..”错误。此外,我在 Eclipse 的问题部分中丢失了工件错误。
Where does the m2-plugin or Eclipse read those dependencies, if they show up correctly on pom.xml and the correcponding jar is at .m2 folder?
m2-plugin 或 Eclipse 在哪里读取这些依赖项,如果它们在 pom.xml 上正确显示并且相应的 jar 位于 .m2 文件夹中?
采纳答案by mico
I removed check from "Do not automatically update dependencies from remote repositories" option and that made the trick.
我从“不自动更新远程存储库的依赖项”选项中删除了检查,这就是诀窍。
回答by Olimpiu POP
Eclipse produces quite a lot of problems when it comes to M2. What I do to get rid of this problems is to clean the project(Project > Clean...), use an external maven (Window > Preferences > Installations > ...) for building purposes and from the maven settings of a project I Update Project configuration (Right click on the project > Maven > Update project ...).
当涉及到 M2 时,Eclipse 会产生很多问题。我为摆脱这个问题所做的是清理项目(项目 > 清理...),使用外部 Maven(窗口 > 首选项 > 安装 > ...)用于构建目的,并从我的项目的 Maven 设置中更新项目配置(右键单击项目> Maven > 更新项目...)。
Hope this helps.
希望这可以帮助。
回答by Miquel
Eclipse will sometimes need a kick like user503413 says (and a restart), but sometimes it's also right: make sure that in $HOME/.m2/repository/
you indeed have the dependencies you want (that's where maven, and therefore m2eclipse through maven) will put them. If they arethere, make sure the pom makes sense. Fix if needed, and... then clean up and restart eclipse just in case ;)
Eclipse 有时需要像 user503413 所说的那样(并重新启动),但有时它也是正确的:确保$HOME/.m2/repository/
您确实拥有您想要的依赖项(这就是 maven,因此 m2eclipse 通过 maven)将放置它们。如果它们在那里,请确保 pom 有意义。如果需要,请修复,然后……然后清理并重新启动 eclipse 以防万一;)
回答by Patrick Fink
Had this problem today with "provided"-scoped dependencies. Solution was to set the "compile"-scope for all dependencies, then build once and after that, recover the original scopes.
今天在“提供”范围的依赖项中遇到了这个问题。解决方案是为所有依赖项设置“编译”范围,然后构建一次,然后恢复原始范围。
回答by troyfolger
I've had this problem when my project is a Java project but not a Maven project. Close project, delete (don't check the box to delete files), and then re-import the project as an Existing Maven Project. I think this is a common way the problem occurs.
当我的项目是 Java 项目而不是 Maven 项目时,我遇到了这个问题。关闭项目,删除(不要勾选删除文件的框),然后将项目作为 Existing Maven Project 重新导入。我认为这是出现问题的常见方式。