修复了IntelliJ 14之前的问题
文件[菜单]->设置-> maven ->导入和取消选中“使用maven3导入项目”
参考:http://youtrack.jetbrains.com/issue/IDEA-98425(可能也有一些其他的想法)
修正IntelliJ 15+
Ran into this again, with IntelliJ 15 this time, which has no "use maven3 to import" option available anymore. The cause was that sometimes IntelliJ "doesn't parse maven dependencies right" and if it can't parse one of them right, it gives up on all of them, apparently. You can tell if this is the case by opening the maven projects tool window (View menu -> Tool Windows -> Maven Projects). Then expand one of your maven projects and its dependencies. If the dependencies are all underlined in red, "Houston, we have a problem".
通过将鼠标移到项目名称本身上,您实际上可以看到真正的失败。
在我的实例中,它显示“问题:XXX没有可用版本”或“读取工件org.xy的描述符失败”。z"参考:https://youtrack.jetbrains.com/issue/IDEA-128846
而且
https://youtrack.jetbrains.com/issue/IDEA-152555
It seems in this case I was dealing with a jar that didn't have an associated pom file (in our maven nexus repo, and also my local repository). If this is also your problem, "urrent work around: if you do not actually need to use classes from that jar in your own code (for instance a transitive maven dependency only), you can actually get away with commenting it out from the pom (temporarily), maven project reload, and then uncomment it. Somehow after that point IntelliJ "remembers" its old working dependencies. Adding a maven transitive exclude temporarily might also do it, if you're running into it from transitive chain of dependencies."
另一件可能有帮助的事情是使用maven的“更新版本”,而不是捆绑的3.0.5。
为了将其设置为默认使用,关闭所有intellij窗口,然后打开首选项->构建,执行和部署->构建工具-> maven,并更改maven主目录,当你调整这个时,它应该在顶部显示“For default project”,尽管你也可以为特定的项目调整它,只要你在调整后“重新导入”即可。
清除缓存
删除intellij缓存文件夹(windows: HOMEPATH/。{IntellijIdea,IdeaC}XXX linux ~/. ideaic15)和/或卸载并重新安装IntelliJ本身。这也可以通过去文件[菜单]->无效缓存/重新启动....单击“无效并重新启动”。这将重新索引整个项目,并用IntelliJ解决许多难以跟踪的问题。