Java 如何立即在 IntelliJ Idea 的项目树中看到编译错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2502517/
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
How to immediately see compile errors in project tree of IntelliJ Idea?
提问by magomi
I'm wondering if it is possible to configure IntelliJ Idea to immediately show compile errors on the class files in the project tree. Currently I need to manually trigger the recompilation to see error marks on my classes if the class cannot be compiled.
我想知道是否可以将 IntelliJ Idea 配置为立即在项目树中的类文件上显示编译错误。目前,如果无法编译类,我需要手动触发重新编译以查看类上的错误标记。
采纳答案by raymi
As of IntelliJ 12 there's an option to automatically build your project upon source changes. In "Settings" --> Build, Execution, Deployment --> "Compiler" check the checkbox "Build project automatically". This will immediately show any compile errors in the project tree.
从 IntelliJ 12 开始,有一个选项可以根据源代码更改自动构建您的项目。在“设置”--> 构建、执行、部署-->“编译器”中,选中“自动构建项目”复选框。这将立即在项目树中显示任何编译错误。
回答by codefinger
You might try the Eclipse Mode plugin for IntelliJ. It allows you to do incremental compile upon saving a file:
您可以尝试 IntelliJ 的 Eclipse 模式插件。它允许您在保存文件时进行增量编译:
回答by magomi
I did some further searches in the web about this feature. At the end it seems that exactly this feature is not available. There are some discussions about this topic where also some (in my point of view) workarounds are mentioned. The most helpful discussion I found here.
我在网上对这个功能做了一些进一步的搜索。最后似乎正是这个功能不可用。有一些关于这个主题的讨论,其中也提到了一些(在我看来)解决方法。我在这里找到的最有帮助的讨论。
回答by Nathan Beach
You can access all the compile problems like so:
您可以像这样访问所有编译问题:
- open the "Project" explorer (usually docked on the left)
- click the "Project" dropdown in the upper left corner
- select "Problems" under "Scopes"
- 打开“项目”资源管理器(通常停靠在左侧)
- 单击左上角的“项目”下拉菜单
- 在“范围”下选择“问题”
You'll see a tree of files and problems. Also, on the bottom toolbar, you should see a tab called "Problems" which lists everything as well. It's not as easy to use as the Eclipse "Problems" view, but it's close.
您将看到一棵文件和问题树。此外,在底部工具栏上,您应该看到一个名为“问题”的选项卡,其中列出了所有内容。它不像 Eclipse“问题”视图那样易于使用,但它很接近。
I'm on version 12.1.4, not sure what version this feature first came in, though.
我使用的是 12.1.4 版,但不确定此功能最初是哪个版本。