简体   繁体   English

如何在Eclipse中更改“已安装的项目方面”的Java版本?

[英]How do I change the Java version of my “installed project facet” in Eclipse?

I just installed Eclipse 3.7 and the Google Plugin for Eclipse because I want to teach myself how to use Google App Engine. 我刚刚安装了Eclipse 3.7和Eclipse插件,因为我想教自己如何使用Google App Engine。

When I create a new web application and run, I got an error that noted that annotations were not allowed in my JRE version (1.4). 当我创建一个新的Web应用程序并运行时,我收到一条错误,指出我的JRE版本(1.4)中不允许使用注释。 Hence, I set my JRE to 1.6 and my compiler compliance level to 1.6. 因此,我将JRE设置为1.6,将编译器合规性级别设置为1.6。

However, I now get this new error. 但是,我现在得到这个新错误。

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

How do I change "the version of the installed Java project facet"? 如何更改“已安装的Java项目方面的版本”?

There is no item called "Project Facet" to the left of my project's properties menu. 项目属性菜单左侧没有名为“Project Facet”的项目。

If you are getting that validation message, you should be able to find "Project Facets" under your project's properties. 如果您收到验证消息,您应该能够在项目属性下找到“Project Facets”。 You should see a screen like this one, where you will be able to change Java facet version: 您应该看到一个像这样的屏幕,您可以在其中更改Java facet版本:

在此输入图像描述

If you are not seeing this page, then the project you created is likely corrupted somehow. 如果您没有看到此页面,那么您创建的项目可能会以某种方式损坏。 How did you create it? 你是怎么创造它的? Did you use a wizard provided by Google Plugin for Eclipse? 您是否使用了Google Plugin for Eclipse提供的向导? If so, you will need to file a bug report with Google as they are not creating a valid project. 如果是这样,您需要向Google提交错误报告,因为他们没有创建有效的项目。

Regardless of the above, you should be able to resolve this problem by right clicking on the problem in the problems view and selecting "quick fix", where you will be guided in aligning your java facet and java compliance settings. 无论上述情况如何,您都应该能够通过右键单击问题视图中的问题并选择“快速修复”来解决此问题,您将在这里指导您调整java方面和java合规性设置。

In case you have not yet found a solution or somebody else is facing this problem: 如果您还没有找到解决方案或其他人遇到此问题:

I had the same problem with the "Project facet" and not having the "Project Facets" page in the project properties when switching from 1.7 down to 1.6. 我从“项目方面”遇到了同样的问题,并且当从1.7切换到1.6时,项目属性中没有“项目构面”页面。 I was able to fix it with editing the file org.eclipse.wst.common.project.facet.core.xml in the project folder .settings . 我能够通过编辑项目文件夹.settings中的文件org.eclipse.wst.common.project.facet.core.xml来修复它。

In this file I had the following code, in which the 1.7 was replaced by 1.6 and the error went away: 在这个文件中我有以下代码,其中1.7被1.6替换,错误消失了:

    <?xml version="1.0" encoding="UTF-8"?>
    <faceted-project>
    <installed facet="java" version="1.7"/>
    </faceted-project>

EDIT: I forgot to mention that you have to edit the filters on the "Package Explorer" to show .* resources: Select "View Menu" (the down-facing arrow) -> Filters... -> uncheck ".* resources" -> click "Ok" and you should see the .settings folder. 编辑:我忘了提到你必须在“Package Explorer”上编辑过滤器以显示。*资源:选择“查看菜单”(向下箭头) - >过滤器... - >取消选中“。*资源“ - >单击”确定“,您应该看到.settings文件夹。

If you are using Eclipse IDE for Java EE Developers , you should have the Project Facets property section. 如果您使用Eclipse IDE for Java EE Developers ,则应该具有Project Facets属性部分。

It is possible that your Eclipse 3.7 is the Eclipse IDE for Java Developers . Eclipse 3.7可能是Eclipse IDE for Java DevelopersEclipse IDE for Java Developers In that case you need to add the ability to have facets by installing the EE goodies... 在这种情况下,你需要通过安装EE好东西添加具有facet的能力......

use the Help -> Install New Software... -> Work with: (choose Indigo) and then turn down "Web, XML, Java EE and OSGi Enterprise Development" and check Eclipse Java EE Developer Tools 使用帮助 - >安装新软件... - >使用:(选择Indigo)然后调低“Web,XML,Java EE和OSGi企业开发”并检查Eclipse Java EE Developer Tools

Allowing Eclipse to be restarted should now add the Project Facets property section visibility. 现在,允许重新启动Eclipse应该添加Project Facets属性部分可见性。

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

相关问题 如何将我的 Eclipse 项目转换为早期的 Java 版本? - How do I convert my Eclipse project to an earlier Java version? 如何解决这个项目方面的日食? - how do i resolve this project facet in eclipse? 如何将受版本控制的 Eclipse 中的本地 Java 项目推送到 GitHub? - How do I push my local Java project in Eclipse that is version controlled to GitHub? 如何将我的项目的新版本上传到SVN(eclipse)? - How do I upload a new version of my project to SVN (eclipse)? Eclipse / maven - “无法将项目方面的EAR版本更改为6.0 - Eclipse/maven - "Cannot change version of project facet EAR to 6.0 Eclipse:无法将项目构面动态Web模块的版本更改为2.3 - Eclipse: Cannot change version of project facet Dynamic Web Module to 2.3 如何在 Eclipse 中修复“无法将项目方面动态 Web 模块的版本更改为 2.4”? - How to fix “Cannot change version of project facet Dynamic Web Module to 2.4” in Eclipse? 不支持Project Facet Java版本1.8,Tomcat 9,Eclipse Oxygen - Project facet Java version 1.8 is not supported, Tomcat 9, Eclipse Oxygen 即使我的java是1.7,也无法将Project Facet动态Web模块的版本更改为3.0 - cannot change version of project facet dynamic web module to 3.0 even if my java is 1.7 如何在 Eclipse 中向我的 Java 项目添加资源文件夹 - How do I add a resources folder to my Java project in Eclipse
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM