Java 编译器级别与安装的 Java 项目构面的版本不匹配
我在 Eclipse Helios 版本下创建了一个新的动态项目,其中我的 JRE 版本设置为 1.6。 我已通过单击“配置”→“转换为 Maven 项目”将 Maven 功能添加到 Web 应用程序。
添加此内容后,Eclipse Problems 视图中出现构建错误:
Java compiler level does not match the version of the installed Java project facet.
Unknown Faceted Project Problem (Java Version Mismatch)
请告诉我如何解决此错误(我希望我的 JRE 版本仅为 1.6)。
I have created a New Dynamic Project under Eclipse Helios Version, where my JRE Version is set to 1.6.
I have added Maven capabilities to the Web Application by clicking on Configure → Convert to Maven Project.
After adding this, a build error appeared in the Eclipse Problems view:
Java compiler level does not match the version of the installed Java project facet.
Unknown Faceted Project Problem (Java Version Mismatch)
Please tell me how to resolve this error (I want to have my JRE version as 1.6 only).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(12)
如果您的项目不是 Maven 项目,请右键单击您的项目并选择“属性”以打开“项目属性”对话框。
左侧有一个 Project Facets 项,选择它,在列表中查找 Java Facet,选择要用于项目的版本并应用。
If your project is not a Maven project, right-click on your project and choose Properties to open the Project Properties dialog.
There is a Project Facets item on the left, select it, look for the Java facet on the list, choose which version you want to use for the project and apply.
假设您在 Eclipse 中使用 m2e 插件,则需要将
maven-compiler-plugin
的source
和target
版本指定为 1.6 >。 m2e 使用这些值来确定项目的 Java 编译器级别。 POM 的片段如下所示:或者,您可以指定值为 1.6 的
maven.compiler.source
和maven.compiler.target
属性,这恰好是等价的:Assuming that you are using the m2e plugin in Eclipse, you'll need to specify the
source
andtarget
versions as 1.6 formaven-compiler-plugin
. m2e uses these values to determine the project's Java compiler level. A snippet of the POM is shown below:Alternatively, you can specify the
maven.compiler.source
andmaven.compiler.target
properties with values of 1.6, that happen to be the equivalent:即使对于 Maven 项目,TK Gospodinov 的答案也是正确的。注意:我确实使用 Maven。 pom是正确的,但仍然遇到这个问题。我转到“Project Facets”,实际上删除了指向 1.6 的 Java 选择,但我的项目正在使用 1.7。在右侧的“运行时”选项卡中,我必须检查 jdk1.7 选项。即使我点击“应用”后,左侧也没有出现任何内容。这个问题消失了,但这就是为什么我仍然认为这个答案对于特定的“Project Facets”相关问题很重要。单击“确定”后,如果返回“Project Facets”,您会注意到 Java 显示为版本 1.7,因此您现在可以选择它以确保该项目被“标记”为 Java 项目。我还需要右键单击该项目并选择 Maven|更新项目。
TK Gospodinov answer is correct even for maven projects. Beware: I do use Maven. The pom was correct and still got this issue. I went to "Project Facets" and actually removed the Java selection which was pointing to 1.6 but my project is using 1.7. On the right in the "Runtimes" tab I had to check the jdk1.7 option. Nothing appeared on the left even after I hit "Apply". The issue went away though which is why I still think this answer is important of the specific "Project Facets" related issue. After you hit OK if you come back to "Project Facets" you will notice Java shows up as version 1.7 so you can now select it to make sure the project is "marked" as a Java project. I also needed to right click on the project and select Maven|Update Project.
我发现@bigleftie 上面的评论非常有帮助:
“有四件事必须匹配
就我而言,在项目属性、Java 编译器、JDK 合规性中设置为使用工作区设置,这与项目的 java 版本不同。我单击“配置工作区设置”,并将工作区编译器合规性级别更改为我想要的,问题得到解决。
I found @bigleftie's comment above very helpful:
"Four things must match
In my case, in the project properties, Java compiler, the JDK compliance was set to use the workspace settings, which were different from the java version for the project. I clicked on 'Configure Workspace Settings', and changed the workspace Compiler compliance level to what I wanted, and the problem was resolved.
我通过在项目属性的Project Facet属性中设置java版本解决了这个问题,右键单击项目根文件夹->属性,搜索 Project Facets,然后选择兼容的 java 版本。
供参考 -
I resolved this problem by setting the java version in Project Facet property of the project properties, Right click the project root folder -> Properties, search for Project Facets, and select compatible java version.
For reference -
我通过 Myproject--->java Resource---->libraries-->JRE System 解决了它库[java-1.6] 单击此转到其“属性”,选择“类路径容器” 将执行环境更改为java-1.8(jdk1.8.0-35)(即最新)
I resolved it by Myproject--->java Resource---->libraries-->JRE System Libraries[java-1.6] click on this go to its "property" select "Classpath Container" change the Execution Environment to java-1.8(jdk1.8.0-35) (that is latest)
我将
workspace/project/.setting/org.eclipse.wst.common.project.facet.core
中的配置更改为:在更改配置之前,从 IDE 中删除项目。
这对我有用。
I changed the configuration inside
workspace/project/.setting/org.eclipse.wst.common.project.facet.core
to :Before changing config, remove project from IDE.
This worked for me.
Project Facet->Java 应该与 pom.xml 中的 maven-compiler-plugin 工件源和目标相匹配。这是完美的。但是如果这里没有它,那么您也可以通过匹配 Java 编译器来修复它Porject-Facets 中的版本设置:Eclispe->Preferences->Java->Compiler
The Project Facet->Java should match whatever you have in the pom.xml for the maven-compiler-plugin artifact source and target.This is perfect.But if you donot have it here then you can also fix it by matching Java compiler version in Porject-Facets from the setting: Eclispe->Preferences->Java->Compiler
您可以更改项目方面
项目-->属性-->项目方面--> Java --> {所需的JDK版本}
You can change project facet from
Project --> Properties --> Project Facet --> Java --> {required JDK version}
右键单击项目并选择属性
点击左边的java编译器,改成你需要的版本
希望这有帮助
Right click the project and select properties
Click the java compiler from the left and change to your required version
Hope this helps
在 Eclipse 中,右键单击您的项目,转到 Maven>更新项目。等待,错误就会消失。这已经正确配置了该项目的 Java 版本。
In Eclipse, right click on your project, go to Maven> Update projetc. Wait and the error will disappear. This is already configured correctly the version of Java for this project.
如果使用eclipse,
在settings下点击org.eclipse.wst.common.project.facet.core.xml
将版本更改为正确的版本。
If using eclipse,
Under.settings click on org.eclipse.wst.common.project.facet.core.xml
Change the version to the correct version.