如何使用 JDK8 在 Eclipse 中导入 javax.faces 库?

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

How to import javax.faces library in Eclipse using JDK8?

eclipsejsfimportjava-8java

提问by 030

Based on the advice to use JSF, the following samplewould like to be run in order to learn more about JSF and to implement this technique into the servlet. However, a number of libraries is unable to be imported:

根据使用 JSF建议,希望运行以下示例以了解有关 JSF 的更多信息并将此技术实现到 servlet 中。但是,许多库无法导入:

package tobedefinedservlet;

import javax.faces.bean.ManagedBean;

@ManagedBean
public class Hello {

    final String world = "Hello World!";

    public String getworld() {
        return world;
    }
}

javax.faces

javax.faces

The import javax.faces cannot be resolved

The import javax.faces cannot be resolved

ManagedBean

托管Bean

ManagedBean cannot be resolved to a type

ManagedBean cannot be resolved to a type

采纳答案by LarsBauer

You have to include a JSF library like for example Mojarra in the classpath of your application.

您必须在应用程序的类路径中包含一个 JSF 库,例如 Mojarra。

First of all have a look at the Primefaces user guide(especially chapter 2.2). You can download e.g. Mojarra hereand include the JAR or add the dependencyto your POM.xml if you are using Maven. Hope that helps.

首先看看 Primefaces用户指南(尤其是第 2.2 章)。您可以下载如钻嘴鱼科在这里和包括JAR或添加依赖于你的pom.xml如果你正在使用Maven。希望有帮助。

回答by J Woodchuck

If you're using mavenfor build automation, add the latest jsf-apidependency to your pom.xml:

如果您使用maven进行构建自动化,请将最新的jsf-api依赖项添加到您的 pom.xml:

<dependency>
    <groupId>javax.faces</groupId>
    <artifactId>jsf-api</artifactId>
    <version>2.1</version>
</dependency>

Or the latest javax.faces-apiimplementation:

或者最新的javax.faces-api实现

<dependency>
  <groupId>javax.faces</groupId>
  <artifactId>javax.faces-api</artifactId>
  <version>2.3</version>
</dependency>

However, note that JSF is integratedinto most Java EE application servers, such as JBoss.

但是,请注意 JSF 已集成到大多数 Java EE 应用程序服务器中,例如 JBoss。

See also this answer.

另请参阅此答案

回答by Henry Vargas Guevara

in my case ...I went to project properties and in the search engine I wrote facets ... I went to the right of the window and selected the runtime tab and select wildfly ... then apply and apply and close and solve ...

就我而言...我去了项目属性,在搜索引擎中我写了方面...我去了窗口的右边,选择了运行时选项卡,然后选择了wildfly...然后应用和应用关闭并解决。 ..

回答by Michael

If you're not using maven you have to manually install the jar. You can download it at this link:

如果您不使用 maven,则必须手动安装 jar。你可以在这个链接下载它:

javax.faces

javax.faces

If you're using eclipse you can right click your Web App project and click properties at the bottom. Then under the java build path make sure the libraries panel at the top is selected then select the Web App library and on the right click Add External JARS. You can go to your downloads folder and select the jsf-api-2.1.jar and refresh the project and you can now import that annotation.

如果您使用的是 Eclipse,您可以右键单击您的 Web App 项目,然后单击底部的属性。然后在 java 构建路径下确保选择顶部的库面板,然后选择 Web App 库并在右侧单击添加外部 JARS。您可以转到您的下载文件夹并选择 jsf-api-2.1.jar 并刷新项目,您现在可以导入该注释。