JavaEE 中的“Facet”是什么?

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

What is 'Facet' in JavaEE?

javaidejakarta-eeterminologyfacet

提问by Roman

I wonder not only what is Facet but also what is Facet 'in physical level' (as I understand it's not a separate jar, but what?)?

我不仅想知道什么是 Facet,还想知道什么是“物理层面”的 Facet(据我所知,它不是一个单独的罐子,而是什么?)?

I also wonder how can it affect my application after deploying. I'll explain on real example:

我也想知道它在部署后如何影响我的应用程序。我会用真实的例子来解释:

I had 2 facets (which were created by IDE): Spring Facet and Web Facet (for jsf). I deployed it to Tomcat and my application worked fine.

我有 2 个方面(由 IDE 创建):Spring Facet 和 Web Facet(用于 jsf)。我将它部署到 Tomcat,我的应用程序运行良好。

Then I added (by means of IDE) one more facet - JPA Facet. I redeployed application and.. it still worked fine :)

然后我(通过 IDE)添加了另一个方面 - JPA Facet。我重新部署了应用程序并且..它仍然可以正常工作:)

So, I'm just curious what is that and why do we need it?

所以,我只是好奇那是什么,为什么我们需要它?

采纳答案by BalusC

This is not Java EE related. This is IDE related. The term is at its own not programming related.

这与 Java EE 无关。这是 IDE 相关的。该术语本身与编程无关。

From http://www.thefreedictionary.com/facet

来自http://www.thefreedictionary.com/facet

fac·et(fst) n.

  1. One of the flat polished surfaces cut on a gemstone or occurring naturally on a crystal.
  2. AnatomyA small, smooth, flat surface, as on a bone or tooth.
  3. BiologyOne of the lenslike visual units of a compound eye, as of an insect.
  4. One of numerous aspects, as of a subject. See Synonyms at phase.

fac·et(fst) n.

  1. 其中一个平坦的抛光表面切割在宝石上或自然出现在水晶上。
  2. 解剖学一个小的、光滑、平坦的表面,如骨骼或牙齿上。
  3. 生物学复眼的透镜状视觉单位之一,如昆虫。
  4. 众多方面之一,作为一个主题。参见阶段的同义词。

It's 4.

是 4。

In this specific case it's just an aspect which is to be used in the project, so that the IDE can intercept on it with regard to generators, wizards, auto-include libraries and so on. If you add for example the JPAfacet, then you will get more options to do the IDE-magic with JPA.

在这种特定情况下,它只是要在项目中使用的一个方面,以便 IDE 可以在生成器、向导、自动包含库等方面拦截它。如果您添加例如JPAfacet,那么您将获得更多选项来使用 JPA 执行 IDE-magic。

回答by Pascal Thivent

As BalusC said, this is not Java EE related but IDE related. This allows to add "characteristics" to a project in a flexible way.

正如 BalusC 所说,这与 Java EE 无关,而是与 IDE 相关。这允许以灵活的方式向项目添加“特征”。

From the IntelliJ IDEA Q&A for Eclipse Users(because you mentioned IDEA):

来自Eclipse 用户IntelliJ IDEA 问答(因为您提到了 IDEA):

Q:Facets — what they are for?

A:To streamline the project configuration.

Facets encapsulate the support for a variety of frameworks, technologies and languages. For example, to enable Spring in your project, you only have to add the corresponding facet. All libraries are downloaded and configured, you get the full range of coding assistance, refactorings, etc. Moreover, the code model is also recognized, so you are completely free from worrying about any configuration issues.

In most cases, you can add more than one facet of the same type to your project. For example, you can have multiple Web facets for deploying the application to different servers, or several EJB facets, each for its own EJB version. (See also Project Configuration.)

问:刻面——它们的用途是什么?

- 答:简化项目配置。

Facets 封装了对各种框架、技术和语言的支持。例如,要在您的项目中启用 Spring,您只需添加相应的 facet。所有的库都下载并配置好,你得到全方位的编码帮助、重构等。而且,代码模型也得到了认可,让你完全不用担心任何配置问题。

在大多数情况下,您可以向项目中添加多个相同类型的方面。例如,您可以有多个 Web facet 用于将应用程序部署到不同的服务器,或多个 EJB facet,每个面向其自己的 EJB 版本。(另请参阅项目配置。)

And yes, Eclipse uses "Facets" too:

是的,Eclipse 也使用“Facets”:

alt text

替代文字

AFAIK, NetBeans doesn't (see Q:How do I configure a web framework for my project?).

AFAIK,NetBeans 没有(请参阅问:如何为我的项目配置 Web 框架?)。

回答by armin

Facets is a web application framework that leverages a simple MVC architecture for the server side and a feature-packed Javascript component model for the client. The two pieces are designed to be seemlessly integrated for very dynamic AJAX-style apps

Facets 是一个 Web 应用程序框架,它利用服务器端的简单 MVC 架构和客户端的功能丰富的 Javascript 组件模型。这两个部分旨在无缝集成非常动态的 AJAX 风格的应用程序

回答by blueray

As explained in Eclipse& Intellijdocumentation, Facets define characteristics and requirements (certain configuration, specific for a particular framework/technology).

正如EclipseIntellij文档中所解释的,Facets 定义了特性和要求(特定配置,特定于特定框架/技术)。

When you add a facet to a project, that project is configured to perform a certain task, fulfill certain requirements, or have certain characteristics.

当您向项目添加构面时,该项目被配置为执行特定任务、满足特定要求或具有特定特征。

In Brief You Have to Follow Some structure to Implement some framework/technology. IDEs have options to implement it for you to make your life easier.

简而言之,您必须遵循一些结构来实现一些框架/技术。IDE 可以选择为您实现它,让您的生活更轻松。

To elaborate it in details I am giving some thorough details directly from Eclipse Documentations. This is Eclipse specific.

为了详细说明它,我直接从 Eclipse 文档中提供了一些详尽的细节。这是Eclipse 特定的

While creating a projectyou will get the option to implement facet for your project. For example, the EAR facet sets up a project to function as an enterprise application by adding a deployment descriptor and setting up the project's classpath.

创建项目时,您将获得为项目实施 facet 的选项。例如,EAR facet 通过添加部署描述符和设置项目的类路径来设置项目以用作企业应用程序。

To add another facet to a projectthat already exists, complete the following steps:

要将另一个方面添加到已存在的项目,请完成以下步骤:

  1. In the Project Explorer view of the Java? EE perspective, right-click the project and then select Properties.
  2. Select the Project Facets page in the in the Properties window. This page lists the facets in the project and their versions.
  3. Click Modify Project and select the check boxes next to the facets you want the project to have.
  1. 在 Java 的 Project Explorer 视图中?EE透视,右击项目然后选择Properties。
  2. 在“属性”窗口中选择“项目构面”页面。此页面列出了项目中的方面及其版本。
  3. 单击修改项目并选中您希望项目具有的构面旁边的复选框。

Note: Only the facets that are valid for the project are listed

注意:仅列出对项目有效的方面

Some facets may not work together. Thus, you can also choose a preset combination of facets from the Presets list.

某些方面可能无法协同工作。因此,您还可以从预设列表中选择一个预设的构面组合

  1. Choose a version number for the facet by clicking the current version number and selecting the version number you want from the drop-down list.
  2. Optional: To remove a facet, clear its check box. Not all facets can be removed.
  3. Optional: If you want to limit the project so it will be compatible with one or more runtimes, click on the Runtimes tab and select the runtimes that you want the project to be compatible with. For more information on runtimes, see Specifying target servers for J2EE projects.
  4. Click Finish to exit the Modify Faceted Project dialog and then click OK.
  1. 通过单击当前版本号并从下拉列表中选择所需的版本号,为构面选择一个版本号。
  2. 可选:要移除构面,请清除其复选框。并非所有方面都可以删除。
  3. 可选:如果您想限制项目以使其与一个或多个运行时兼容,请单击运行时选项卡并选择您希望项目兼容的运行时。有关运行时的更多信息,请参阅为 J2EE 项目指定目标服务器。
  4. 单击“完成”退出“修改分面项目”对话框,然后单击“确定”。

Facets also have version numbers in Eclipse. You can change the version numbers of facetsas long as you stay within the requirements for the facets. To change the version of a facet in your project, complete the following steps:

Facets 在 Eclipse 中也有版本号。只要您保持在方面的要求范围内,您就可以更改方面的版本号。要更改项目中的构面版本,请完成以下步骤:

  1. In the Project Explorer view of the Java EE perspective, right-click the project and then select Properties.
  2. Select the Project Facets page in the in the Properties window. This page lists the facets in the project and their versions.
  3. Click Modify Project and click the facet you want to change.
  4. Select the version of the facet from the drop-down box next to the facet's name.
  5. Click Finish to close the Modify Faceted Project window and then click OK.
  1. 在 Java EE 透视图的 Project Explorer 视图中,右键单击该项目,然后选择 Properties。
  2. 在“属性”窗口中选择“项目构面”页面。此页面列出了项目中的方面及其版本。
  3. 单击修改项目,然后单击要更改的构面。
  4. 从构面名称旁边的下拉框中选择构面的版本。
  5. 单击“完成”关闭“修改分面项目”窗口,然后单击“确定”。

You can do more things with the facets. I have given the examples for your better understanding. For details, please go through the documentation of your favorite IDE.

您可以使用分面做更多事情。我已经给出了示例以便您更好地理解。有关详细信息,请查看您喜欢的 IDE 的文档。