Java 如何查看 IntelliJ 中的编译错误列表?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19364949/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 16:31:06  来源:igfitidea点击:

How to view the list of compile errors in IntelliJ?

javaintellij-ideacompiler-errors

提问by amphibient

I am looking for a way to view all compile errors in IntelliJ, similar to how they are displayed in Eclipse. I tried searching here and Google but have not really found a solution. I really like IntelliJ, I recently converted to it from Eclipse, and I hope this is just something I am missing and not a fundamental deficiency.

我正在寻找一种在 IntelliJ 中查看所有编译错误的方法,类似于它们在 Eclipse 中的显示方式。我尝试在这里和谷歌搜索,但还没有真正找到解决方案。我真的很喜欢 IntelliJ,我最近从 Eclipse 转换到它,我希望这只是我缺少的东西,而不是根本的缺陷。

采纳答案by Ashutosh Jindal

I think this comes closest to what you wish:

我认为这最接近您的愿望:

(From IntelliJ IDEA Q&A for Eclipse Users):

(来自IntelliJ IDEA Eclipse 用户问答):

enter image description here

在此处输入图片说明

The above can be combined with a recently introduced option in Compiler settings to get a view very similar to that of Eclipse.

以上可以与编译器设置中最近引入的选项相结合,以获得与 Eclipse 非常相似的视图。

Things to do:

要做的事情:

  1. Switch to 'Problems' view in the Project pane:

    enter image description here

  2. Enable the setting to compile the project automatically :

    enter image description here

  3. Finally, look at the Problems view:

    enter image description here

  1. 在“项目”窗格中切换到“问题”视图:

    在此处输入图片说明

  2. 启用设置以自动编译项目:

    在此处输入图片说明

  3. 最后,看一下问题视图:

    在此处输入图片说明

Here is a comparison of what the same project (with a compilation error) looks like in Intellij IDEA 13.xx and Eclipse Kepler:

以下是 Intellij IDEA 13.xx 和 Eclipse Kepler 中相同项目(带有编译错误)的比较:

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明

Relevant Links: The maven project shown above : https://github.com/ajorpheus/CompileTimeErrors
FAQ For 'Eclipse Mode' / 'Automatically Compile' a project : http://devnet.jetbrains.com/docs/DOC-1122

相关链接:上面显示的 maven 项目:https: //github.com/ajorpheus/CompileTimeErrors
FAQ For 'Eclipse Mode'/'Automatically Compile' a project:http: //devnet.jetbrains.com/docs/DOC-1122

回答by Eric Jiang

A more up to date answer for anyone else who comes across this:

对于遇到此问题的任何其他人的最新答案:

(from https://www.jetbrains.com/help/idea/eclipse.html, §Auto-compilation; click for screenshots)

(从https://www.jetbrains.com/help/idea/eclipse.html,§自动编译;点击截屏)

Compile automatically:

自动编译:

To enable automatic compilation, navigate to Settings/Preferences | Build, Execution, Deployment | Compilerand select the Build project automaticallyoption

要启用自动编译,请导航至Settings/Preferences | 构建、执行、部署 | 编译并选择自动生成项目选项

Show all errors in one place:

在一处显示所有错误:

The Problems tool windowappears if the Make project automaticallyoption is enabled in the Compiler settings. It shows a list of problems that were detected on project compilation.

问题的工具窗口,如果出现使项目自动选项在编译器设置中启用。它显示了在项目编译时检测到的问题列表。

Use the Eclipse compiler:This is actually bundled in IntelliJ. It gives much more useful error messages, in my opinion, and, according to this blog, it's much faster since it was designed to run in the background of an IDE and uses incremental compilation.

使用 Eclipse 编译器:这实际上捆绑在 IntelliJ 中。在我看来,它提供了更多有用的错误消息,并且根据这个博客,它的速度要快得多,因为它被设计为在 IDE 的后台运行并使用增量编译。

While Eclipse uses its own compiler, IntelliJ IDEA uses the javac compiler bundled with the project JDK. If you must use the Eclipse compiler, navigate to Settings/Preferences | Build, Execution, Deployment | Compiler | Java Compilerand select it... The biggest difference between the Eclipse and javac compilers is that the Eclipse compiler is more tolerant to errors, and sometimes lets you run code that doesn't compile.

Eclipse 使用自己的编译器,而 IntelliJ IDEA 使用与项目 JDK 捆绑的 javac 编译器。如果您必须使用 Eclipse 编译器,请导航至Settings/Preferences | 构建、执行、部署 | 编译器 | Java Compiler并选择它... Eclipse 和 javac 编译器的最大区别在于 Eclipse 编译器更能容忍错误,有时会让您运行无法编译的代码。

回答by Matthias Bohlen

On my system (IntelliJ Idea 2017.2.5), it was not sufficient to enable "Make Project Automatically". I also had to use the menu item "View, Tool Windows, Problems" to see the problems tool window at the bottom of the screen.

在我的系统(IntelliJ Idea 2017.2.5)上,启用“自动制作项目”是不够的。我还必须使用菜单项“查看、工具窗口、问题”来查看屏幕底部的问题工具窗口。

Opening the problems tool window

Opening the problems tool window

回答by Ammar Bozorgvar

You should disable Power Save Mode

您应该禁用省电模式

For me I clicked over this button

对我来说,我点击了这个按钮

enter image description here

enter image description here

then disable Power Save Mode

然后禁用省电模式