Eclipse 和 Facets

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

Eclipse and Facets

eclipsefacets

提问by toomuchcs

In the courses java, everyone (or at least most people) seemed to have a working eclipse. They always seemed to have a working faces-config (a visual one), and autocomplete in xhtml files (for facelets). Though for autocomplete, we added *.xhtml files on JSP's.

在课程 java 中,每个人(或至少大多数人)似乎都有一个有效的日食。他们似乎总是有一个有效的faces-config(一个可视化的),并在xhtml文件中自动完成(对于facelets)。虽然为了自动完成,我们在 JSP 上添加了 *.xhtml 文件。

It seems that this was a part I don't know well about eclipse, and it's fairly annoying since I don't know why. When I import a project (either Maven or existing), it always has no facets but java (and that in 1.5 not even 1.6), while it is supposed to be a webproject and have facelets & dynamic web project.

似乎这是我对 eclipse 不太了解的部分,而且由于我不知道为什么而相当烦人。当我导入一个项目(无论是 Maven 还是现有项目)时,它总是只有 java(在 1.5 甚至 1.6 中都没有),而它应该是一个 web 项目并且有 facelets 和动态 web 项目。

Can I change those facets? It seems to just work when I put java to 1.6, but trying to edit the dynamic web module version from 2.4 to 2.5 (it is standard on 2.4) without running into some troubles. Even after I just made a fresh maven project (with an archtype in commandline), I'm not able to change much about these facets.

我可以改变这些方面吗?当我将 java 设置为 1.6 时,它似乎可以正常工作,但是尝试将动态 Web 模块版本从 2.4 编辑到 2.5(这是 2.4 的标准版本)而不会遇到一些麻烦。即使我刚刚创建了一个新的 maven 项目(在命令行中有一个 archtype),我也无法改变这些方面。

What am I doing wrong?

我究竟做错了什么?

回答by Konstantin Komissarchik

Eclipse functionality is driven by project metadata. If you don't have the right metadata, the projects aren't going to behave correctly.

Eclipse 功能由项目元数据驱动。如果您没有正确的元数据,项目将无法正常运行。

If you are starting from scratch and creating projects in Eclipse, make sure to place all of the metadata files in your source control system (including everything under [project]/.settings directory).

如果您从头开始并在 Eclipse 中创建项目,请确保将所有元数据文件放在源控制系统中(包括 [project]/.settings 目录下的所有内容)。

If you are using Maven to generate your Eclipse project metadata, make sure that you find the Maven plugin that knows about WTP. I don't have a reference, but I know it exists. This will ensure that when Maven generates metadata, it will have the correct metadata for web projects.

如果您使用 Maven 生成 Eclipse 项目元数据,请确保您找到了解 WTP 的 Maven 插件。我没有参考文献,但我知道它存在。这将确保当 Maven 生成元数据时,它将为 web 项目提供正确的元数据。

Can I change those facets? It seems to just work when I put java to 1.6, but trying to edit the dynamic web module version from 2.4 to 2.5 (it is standard on 2.4) without running into some troubles.

我可以改变这些方面吗?当我将 java 设置为 1.6 时,它似乎可以正常工作,但是尝试将动态 Web 模块版本从 2.4 编辑到 2.5(这是 2.4 的标准版本)而不会遇到一些麻烦。

The way facet works is that the facet author can choose not to implement version change logic. Unfortunately the Java EE module facets (such as the dynamic web module) do not have version change implemented. Other facets like Java do support this. So your experience will vary from facet to facet.

facet 的工作方式是 facet 作者可以选择不实现版本更改逻辑。不幸的是,Java EE 模块方面(例如动态 Web 模块)没有实现版本更改。Java 等其他方面确实支持这一点。因此,您的体验会因方面而异。

If all else fails, you can edit .settings/org.eclipse.wst.common.project.facet.core.xml file by hand. Make sure to do that from Eclipse or you will need to refresh the project afterwards. Just keep in mind that if you are forcing the change like that, you might need to do some manual fixes to your project content. For instance, if you change web spec level, you may need to update the deployment descriptors.

如果一切都失败了,您可以手动编辑 .settings/org.eclipse.wst.common.project.facet.core.xml 文件。确保从 Eclipse 执行此操作,否则您将需要在之后刷新项目。请记住,如果您要强制进行这样的更改,您可能需要对项目内容进行一些手动修复。例如,如果您更改 Web 规范级别,则可能需要更新部署描述符。

回答by Gursel Koca

You can change project facets. You should close eclipse , then goto .settings directory, org.eclipse.wst.common.project.facet.core.xml file holds all facets related info. You can add or remove a project facet .

您可以更改项目方面。您应该关闭 eclipse ,然后转到 .settings 目录,org.eclipse.wst.common.project.facet.core.xml 文件包含所有方面相关信息。您可以添加或删除项目构面。

回答by fmucar

for eclipse

日食

Right click on the project and choose propertiesfrom the appearing menu

Right click on the project 并properties从出现的菜单中选择

There is a list in the left side of the opening window. Select project facetsand you will see all available facets you can choose and adjust their settings.

打开窗口的左侧有一个列表。选择project facets,您将看到所有可用的方面,您可以选择并调整其设置。

回答by Curufin

I recently upgraded an old project to Java8/Eclipse 4.6.1, and also ran into a facet version issue. In order to get the menu mentioned by @fmucar (which was not available in the Eclipse for RCP and RAP Developerspackage I had installed), I had to do Install New Softwarefrom the HelpMenu , and select to add Faceted Project Framework. I was then able to pick the facet version from the IDE.

我最近将一个旧项目升级到 Java8/Eclipse 4.6.1,也遇到了 facet 版本问题。为了获得@fmucar 提到的菜单(在我安装的RCP 和 RAP 开发人员软件包的Eclipse 中不可用),我必须从HelpMenu执行Install New Software,然后选择添加Faceted Project Framework。然后我就可以从 IDE 中选择 facet 版本。