简体   繁体   English

为什么 Intellij 在 pom.xml 中找不到任何 Maven 依赖项?

[英]Why Intellij do not find any Maven dependencies in pom.xml?

I just downloaded Intellij on a laptop and I imported a Maven project and the problem is that Intellij do not found any dependency in pom.xml.我刚刚在笔记本电脑上下载了 Intellij 并导入了 Maven 项目,问题是 Intellij 在 pom.xml 中没有找到任何依赖项。 For example if I try to import hibernate-core or any other dependency I get the error: Dependency org.hibernate-core... not found.例如,如果我尝试导入 hibernate-core 或任何其他依赖项,则会收到错误消息:Dependency org.hibernate-core... not found。 What should I do?我应该怎么办? Any feedback will be appreciated.任何反馈将不胜感激。

In case of Intellij Idea, make right click on pom.xml, select maven and then click to reimport.如果是 Intellij Idea,请右键单击 pom.xml, select maven 然后单击重新导入。 Find below the screenshot.在屏幕截图下方找到。

在此处输入图像描述

I solved this issue by running "mvn idea:idea" command.我通过运行“mvn idea:idea”命令解决了这个问题。 It resolved all module dependencies and also add it to classpath in intellij.它解决了所有模块依赖项并将其添加到 intellij 中的类路径中。

It may also be worth checking which Maven your IDE is using.您的 IDE 正在使用哪个 Maven 也可能值得检查。 You can check it in settings:您可以在设置中检查它:

在此处输入图像描述

We used to have issues with Maven bundled with IntelliJ.我们曾经遇到与 IntelliJ 捆绑的 Maven 的问题。

You could also go to File -> Settings -> Build, Execution, Deployment -> Build Tools -> Maven -> Repositories and check that the local maven repository is set.您还可以 go 到文件 -> 设置 -> 构建、执行、部署 -> 构建工具 -> Maven -> 存储库并检查本地 Z402C5D9AF6B43711EA070BEE5170F 存储库是否已设置。

Same for File -> Settings -> Build, Execution, Deployment -> Remote Jar Repositories where the remote maven repository should be set (something like https://repo1.maven.org/maven2 ) Same for File -> Settings -> Build, Execution, Deployment -> Remote Jar Repositories where the remote maven repository should be set (something like https://repo1.maven.org/maven2 )

After "Maven" > "Reload project" an additional "Build" > "Rebuild project" (in IDEA window menu) was necessary to eliminate all "dependency... not found" error messages in my case.在“Maven”>“重新加载项目”之后,需要额外的“构建”>“重建项目”(在 IDEA window 菜单中)以消除我的所有“依赖项...未找到”错误消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM