简体   繁体   English

Eclipse中的Java资源文件夹错误

[英]Java Resources Folder Error In Eclipse

i am importing a spring maven project in eclipse (helios with maven plugin) i built the project in terminal, and everything is ok, and eclipse shows no errors in xml or java classes, but still it shows an error mark on Java Resources Folder, no idea why ? 我在eclipse中导入了一个Spring Maven项目(带有Maven插件的Helios),在终端中构建了该项目,一切正常,并且eclipse在xml或Java类中均未显示任何错误,但在Java Resources Folder上仍然显示了错误标记,不知道为什么? any ideas ? 有任何想法吗 ?

Well, it might just be because there are some folders containing classes which are treated as source folders by maven (that's why the maven command line compile works) but not as such when using .m2 eclipse plugin to import your project into eclipse. 好吧,可能只是因为有些文件夹包含类,这些类被maven视为源文件夹(这就是maven命令行编译起作用的原因),但在使用.m2 eclipse插件将项目导入eclipse时并非如此。

Here's some things you might try: 您可以尝试以下操作:

in the properties of your eclipse project, go to java build path, select sources, and check to see if all needed source fodlers are added (as source folders). 在eclipse项目的属性中,转到Java构建路径,选择源,然后检查是否已添加所有必需的源文件(作为源文件夹)。 If some are missing, just add them manually using add sources... button 如果缺少某些内容,只需使用添加源...按钮手动添加它们

Sometimes, once you do a maven clean in the command line, the eclipse project will show errors because it no longer finds the compiled classes (they were cleaned by maven). 有时,一旦在命令行中执行了maven清理,eclipse项目就会显示错误,因为它不再找到已编译的类(它们已被maven清理了)。 Doing a Project-> clean on your eclipse project usually solves this 在Eclipse项目上执行Project-> Clean通常可以解决此问题

Try adding the project into eclipse as a plain ole eclipse project: do a mvn eclipse:eclipse, then import it into eclipse as eclipse project (not maven project) 尝试将项目作为普通ole eclipse项目添加到eclipse中:执行mvn eclipse:eclipse,然后将其作为eclipse项目(不是maven项目)导入eclipse中。

I faced similar issue and resolved it by changing the facet for Java to 1.8 as I was using Java 1.8 version and the facet was set to 1.6. 我遇到了类似的问题,并通过将Java的facet更改为1.8(当我使用Java 1.8版本并将facet设置为1.6来解决)。 You can go to the project properties and try changing the facet type. 您可以转到项目属性,然后尝试更改构面类型。

I fixed it by add these plugins into the pom.xml after that Maven > Update Project. 我通过在Maven> Update Project之后将这些插件添加到pom.xml中来修复它。 Then the error was disappeared. 然后错误消失了。

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>3.2.2</version>
            <configuration>
                <warSourceDirectory>src/main/webapp</warSourceDirectory>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>

检查环境变量path和java_home。

This is the problem with Eclipse some times when you build the project from Terminal. 从终端构建项目时,Eclipse有时会出现此问题。 There are a few common steps that we need to apply to solve these kinds of problems. 解决这些问题需要采取一些通用步骤。

  1. Choose Project and clean option from the menu option 从菜单选项中选择“ 项目清理 ”选项
  2. Right Click on Project --> Maven --> Update project 右键单击项目 -> Maven- > 更新项目

Either one should work definitely. 任何一种都应该可以正常工作。

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

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