“分面项目问题(Java 版本不匹配)”错误消息

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

"Faceted Project Problem (Java Version Mismatch)" error message

javaeclipsemaven-2m2eclipse

提问by Blankman

Eclipse's "problems" tab is displaying this error:

Eclipse 的“问题”选项卡显示此错误:

Description: Java compiler level does not match the version of the installed Java project facet.
Resource: groupping
Path: [blank]
Location: Unknown
Type: Faceted Project Problem (Java Version Mismatch)

说明:Java 编译器级别与已安装的 Java 项目方面的版本不匹配。
资源:分组
路径:[空白]
位置:未知
类型:分面项目问题(Java 版本不匹配)

My pom.xmlhas this setting:

pom.xml有这个设置:

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
            <source>1.6</source>
            <target>1.6</target>
        </configuration>
    </plugin>
</plugins>

Where else could the settings be mismatched?

还有哪些设置可能不匹配?

采纳答案by VonC

Did you check your Project Properties -> Project Facetspanel? (From that post)

你检查你的Project Properties -> Project Facets面板了吗?(来自那个帖子

A WTP project is composed of multiple units of functionality (known as facets).

The Java facet version needs to always match the java compiler compliance level.
The best way to change java level is to use the Project Facets properties panel as that will update both places at the same time.

一个 WTP 项目由多个功能单元(称为方面)组成。

Java facet 版本需要始终与 Java 编译器合规性级别相匹配。
更改 java 级别的最佳方法是使用 Project Facets 属性面板,因为它会同时更新两个位置。

WTP

支付意愿

The "Project->Preferences->Project Facets" stores its configuration in this file, "org.eclipse.wst.common.project.facet.core.xml", under the ".settings" directory.

The content might look like this

Project->Preferences->Project Facets”将其配置存储org.eclipse.wst.common.project.facet.core.xml在“ .settings”目录下的“ ”文件中。

内容可能如下所示

<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
  <runtime name="WebSphere Application Server v6.1"/>
  <fixed facet="jst.java"/>
  <fixed facet="jst.web"/>
  <installed facet="jst.java" version="5.0"/>
  <installed facet="jst.web" version="2.4"/>
  <installed facet="jsf.ibm" version="7.0"/>
  <installed facet="jsf.base" version="7.0"/>
  <installed facet="web.jstl" version="1.1"/>
</faceted-project>

Check also your Java compliance level:

还要检查您的Java 合规性级别

Java compliance level

Java compliance level

回答by Anthony Forloney

You have two options to fix the issue:

1- Manually make sure the two versions match.
2- Use the IDE's help as follows:
- Right mouse click on the error in the 'Problems' view
- Select the 'Quick Fix' menu item from the pop-up menu
- Select the right compiler level in the provided dialog and click 'Finish'.

您有两个选项可以解决此问题:

1- 手动确保两个版本匹配。
2- 使用 IDE 的帮助如下:
- 在“问题”视图中右键单击错误
- 从弹出菜单中选择“快速修复”菜单项
- 在提供的对话框中选择正确的编译器级别,然后单击“结束'。

Taken from Eclipse: Java compiler level and project facet mismatch

摘自Eclipse:Java 编译器级别和项目方面不匹配

Also gives location of where you can access the Java compiler and facet version.

还提供了可以访问 Java 编译器和 facet 版本的位置。

回答by Pascal Thivent

The project facets should be derived automagically by the M2Eclipse plugin from the POM configuration. If you make some changes to the POM and need Eclipse to take them into account, right-clickon your project, then go to Maven > Update Project Configuration. You should not set project facets manually.

项目方面应该由 M2Eclipse 插件从 POM 配置自动派生。如果您对 POM 进行了一些更改并需要 Eclipse 将它们考虑在内,请右键单击您的项目,然后转到Maven > Update Project Configuration。您不应手动设置项目构面。

回答by Vengat Maran

In Spring STS, Right click the project & select "Open Project", This provision do the necessary action on the background & bring the project back to work space.

在 Spring STS 中,右键单击项目并选择“打开项目”,此设置在后台执行必要的操作并将项目带回工作空间。

Thanks & Regards Vengat Maran

感谢和问候文加特马兰

回答by DAVE Das

I encountered this issue while running an app on Java 1.6 while I have all three versions of Java 6,7,8 for different apps.I accessed the Navigator View and manually removed the unwanted facet from the facet.core.xml .Clean build and wallah!

我在 Java 1.6 上运行应用程序时遇到了这个问题,而我拥有 Java 6、7、8 的所有三个版本用于不同的应用程序。我访问了导航器视图并从 facet.core.xml 中手动删除了不需要的方面。干净的构建和哇!

<?xml version="1.0" encoding="UTF-8"?>

<fixed facet="jst.java"/>

<fixed facet="jst.web"/>

<installed facet="jst.web" version="2.4"/>

<installed facet="jst.java" version="6.0"/>

<installed facet="jst.utility" version="1.0"/>