如何在 eclipse 用户库中启用 JSF facet

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

How to Enable the JSF facet in eclipse user library

eclipsejsfjakarta-eemojarra

提问by Randnum

I'm having troulbe enabling JSF in Eclipse. I have installed the WPT tools that should have had JSF included but when I right click on my project, properties, facets, enable facets I get a warning saying "Further configuration required" I click this, and I'm notified that "At least one user library must be selected" However there are no libraries to select.

我在 Eclipse 中启用 JSF 时遇到了麻烦。我已经安装了本应包含 JSF 的 WPT 工具,但是当我右键单击我的项目、属性、构面、启用构面时,我收到一条警告说“需要进一步配置”,我单击此按钮,并收到通知“至少必须选择一个用户库”但是没有可供选择的库。

I can optionally select "Disable Library Configuration" but I don't know what effects this might have as Eclipse is telling me that i must configure a user library.

我可以选择“禁用库配置”,但我不知道这可能会产生什么影响,因为 Eclipse 告诉我必须配置用户库。

Should I download a separate Jar from the Mojarra and add this to my build? Or can I safely disable. Why wasn't it included with WTP like it was supposed to be?

我应该从 Mojarra 下载一个单独的 Jar 并将其添加到我的构建中吗?或者我可以安全地禁用。为什么它没有像预期的那样包含在 WTP 中?

回答by BalusC

"At least one user library must be selected" However there are no libraries to select.

“必须至少选择一个用户库” 但是没有可供选择的库。

You have to prepare them yourself by Window > Preferences > Java > Build Path > User Libraries.

您必须通过Window > Preferences > Java > Build Path > User Libraries自己准备它们。



I can optionally select "Disable Library Configuration" but I don't know what effects this might have as Eclipse is telling me that i must configure a user library.

我可以选择“禁用库配置”,但我不知道这可能会产生什么影响,因为 Eclipse 告诉我必须配置用户库。

When you choose this option, Eclispe will also tell you that the user takes the responsibility of configuring the classpath appropriately via alternate means.

当您选择此选项时,Eclispe 还会告诉您用户负责通过其他方式适当地配置类路径。



Should I download a separate Jar from the Mojarra and add this to my build? Or can I safely disable.

我应该从 Mojarra 下载一个单独的 Jar 并将其添加到我的构建中吗?或者我可以安全地禁用。

That's one of the alternative ways. Whether you need to download it yourself depends on the project's target runtime. If it's for example a simple JSP/Servlet container which does not ship with bundled JSF, such as Tomcat 7, then you indeed need to install it yourself. Just dropping the JAR(s) in /WEB-INF/libis sufficient (or defining it as an user library, of course). Eclipse will automagically do the right things for you (adding to build path, including in exported WAR, etc). However, if it's for example a more full fledged Java EE container, such as Glassfish 3, then you don't need to do anything as it already bundles JSF as part of Java EE API. Just disable the library configuration altogether.

这是替代方法之一。是否需要自己下载取决于项目的目标运行时。例如,如果它是一个不附带捆绑 JSF 的简单 JSP/Servlet 容器,例如 Tomcat 7,那么您确实需要自己安装它。只需将 JAR(s) 放入/WEB-INF/lib就足够了(当然,或者将其定义为用户库)。Eclipse 会自动为您做正确的事情(添加到构建路径,包括导出的 WAR 等)。但是,如果它是一个更完整的 Java EE 容器,例如 Glassfish 3,那么您不需要做任何事情,因为它已经将 JSF 捆绑为 Java EE API 的一部分。只需完全禁用库配置。



Why wasn't it included with WTP like it was supposed to be?

为什么它没有像预期的那样包含在 WTP 中?

They have JSF tools included. They do however not include JSF libraries. Or did you read otherwise? If so, where exactly? It must have been a misinformation or misinterpretation.

他们包含 JSF 工具。但是,它们不包括 JSF 库。或者你读过其他的?如果有,具体在哪里?这一定是错误信息或误解。



See also:

也可以看看:

回答by Programmer

Download javax.faces-2.1.17.jar file and create a new library from manage library option and add the jar file in that library. Click apply, now it will work

下载 javax.faces-2.1.17.jar 文件并从管理库选项创建一个新库,并将该 jar 文件添加到该库中。单击应用,现在它将起作用