eclipse/subclipse 项目未显示红线错误

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

eclipse/subclipse project not showing red line errors

javaeclipsesyntax-error

提问by user1007531

I'm working on a group project for school. I checked the project out from the repository. When I write code, the red lines for syntax errors don't show up. So I made a separate java project on my machine and red line errors do show up there. So I don't know whats going on.

我正在为学校做一个小组项目。我从存储库中检出了该项目。当我编写代码时,语法错误的红线不显示。所以我在我的机器上做了一个单独的 java 项目,那里确实出现了红线错误。所以我不知道发生了什么。

回答by john

Eclipse suddenly stopped showing compile errors, both in the code and in the Problems view.

Eclipse 突然停止在代码和问题视图中显示编译错误。

I had created a Dynamic Web Project, added a servlet and everything was groovy; compilation errors showed up properly.

我创建了一个动态 Web 项目,添加了一个 servlet,一切都很好;编译错误正确显示。

I did right click on MyProject->Configure->ConvertToMavenProject and problems started. In my BuildPath, the JRE version was changed from 1.6 to 1.5; this caused some previously unreported compilation problems that went away as soon as I change back to 1.6.

我没有右键单击 MyProject->Configure->ConvertToMavenProject 并且问题开始了。在我的BuildPath中,JRE版本从1.6改为1.5;这导致了一些以前未报告的编译问题,一旦我改回 1.6,这些问题就消失了。

But now, no compilation errors showed up in the code.

但是现在,代码中没有出现编译错误。

The reason was, converting to a maven project also removed my src folder from the build path. I added the src folder back to the build path and things are peachy.

原因是,转换为 maven 项目也会从构建路径中删除我的 src 文件夹。我将 src 文件夹添加回构建路径,事情很顺利。

回答by Arend v. Reinersdorff

Right-click your project and go to Properties > Java Build Path > Source.

右键单击您的项目并转到Properties > Java Build Path > Source

Make sure your source directory (for example MyProject/src) is listed as a Source folder. Otherwise you won't get any red markers.

确保您的源目录(例如MyProject/src)被列为源文件夹。否则你不会得到任何红色标记。

回答by polster

I had this problem as well. After a project --> clean, I'm back to normal.

我也有这个问题。经过一个项目 --> 干净,我恢复了正常。

Edit ... Happened again - realized that I had accidentally unchecked the "Project --> build-automatically" menu option. Now working as expected.

编辑...再次发生 - 意识到我不小心取消了“项目 --> 自动构建”菜单选项。现在按预期工作。

回答by user3764792

Go to check whether in your Java Build Path -> Libraries has a missing jar. When I remove that missing jar in my case, the auto-error shows again.

去检查您的 Java Build Path -> Libraries 中是否缺少 jar。当我在我的情况下删除丢失的 jar 时,自动错误再次显示。

回答by Dave Newton

Squiggles are configurable; in Preferences see General -> Appearance -> Editors -> Text Editors -> Annotations and the "Errors" annotation type.

波浪线是可配置的;在 Preferences 中看到 General -> Appearance -> Editors -> Text Editors -> Annotations 和“Errors”注释类型。

回答by jbranchaud

Make sure your .project file looks something like this:

确保您的 .project 文件如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>ProjectName</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.jdt.core.javanature</nature>
    </natures>
</projectDescription>

If it doesn't look like the above, then you aren't going to get syntax checking, as well as a number of other features that come along with Java projects.

如果它看起来不像上面那样,那么您将无法进行语法检查以及 Java 项目附带的许多其他功能。