java Intellij IDEA 中的“无法解析符号”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31140521/
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
"Cannot resolve symbol" in Intellij IDEA
提问by Mark Williams
I'm fairly new to Intellij and Java and am unable to use libraries from one "module" in another. I am seeing red class names and getting "Cannot resolve symbol ..." errors all over the place:
我对 Intellij 和 Java 还很陌生,无法在另一个“模块”中使用库。我看到红色的类名并且到处都是“无法解析符号......”错误:
The other modules are referenced in File | Project Structure all the other module's Paths are correct and include the *.classes I'm trying to use:
其他模块在 File | 中引用。项目结构所有其他模块的路径都是正确的,包括我尝试使用的 *.classes:
I have also tried a File | Invalidate Caches but am still having the same problems.
我也试过一个文件 | 使缓存无效,但仍然有同样的问题。
What do I need to do to fix this?
我需要做什么来解决这个问题?
回答by Alan
You need to add your external libraries/classes under dependencies in order for IDEA to see them when doing code analysis/autocomplete.
您需要在依赖项下添加外部库/类,以便 IDEA 在进行代码分析/自动完成时看到它们。
回答by Mark Williams
After you add dependencies to POM file, make it a habit to refresh POM by clicking on the 'Reimports maven projects' icon. Its the first icon in the maven tool window located to the right of the main intellij editor. Its a blue icon with 2 circular arrows. Clicking it ensures that the added dependencies are fully integrated into your project
将依赖项添加到 POM 文件后,通过单击“重新导入 maven 项目”图标来刷新 POM。它是位于主 Intellij 编辑器右侧的 maven 工具窗口中的第一个图标。它是一个带有 2 个圆形箭头的蓝色图标。单击它可确保添加的依赖项完全集成到您的项目中