官术网_书友最值得收藏!

Adding the PrimeFaces library and related dependencies to our project

We will use Maven to add all the required resources that we don't create ourselves, and this section will help us to understand how we add libraries to our project. PrimeFaces only requires that the PrimeFaces JAR file be added to our project. So, this is what we do:

  1. By clicking on the + symbol to the left of the project in the Project view, we open the project tree, as follows:
    Adding the PrimeFaces library and related dependencies to our project

    The following is a brief explanation of the folders, as listed in the previous screenshot:

    • Web Pages: This is where we will add views or pages to our application.
    • Source Packages: Here, Java source code is managed.
    • Other Sources: This allows us to add other types of files which may be needed for the project. We will use this facility. So, its purpose should become clear, eventually.
    • Dependencies: Here we tell Maven the JAR files that we want to add to our project.
    • Runtime Dependencies and Java Dependencies: These are not important for this project. Feel free to browse them at your leisure.
    • Project Files: This is where NetBeans manages both the Maven project's pom.xml file and the NetBeans project configuration file. While we don't need to look at these now, we will visit the pom.xml file in the later chapters. So, if you want to preview these files, please feel free to do so.
  2. Meanwhile, we are going to add PrimeFaces 5.2 to our project. Right-click on the Dependencies folder and select Add Dependency... from the context menu. This opens the Add Dependency dialog box, as shown in the following screenshot:
    Adding the PrimeFaces library and related dependencies to our project

    Usually, you only have the Search tab available in a newly created project.

    Tip

    Maven allows us to add local projects as dependencies to a project, which is what the Open Projects tab is for. It also allows us to add dependencies that are defined in a parent Maven project file, and this is what the Dependency Management tab is for.

  3. Type org.primefaces into the Query field of the Search tab, and then go and make a drink or something that takes a little time.

    Tip

    Not only have we earned a break, but we also need time to allow Maven to download and install the Maven Central Repository index in our local Maven repository. This takes time because there are a very large number of resources available there. If you already use Maven for your projects, you obviously won't need a lot of time. The break might be welcome, though.

    Once the Maven Central Repository index is available, you will see something like this:

    Adding the PrimeFaces library and related dependencies to our project
  4. Select the 5.2 version and click on Add. Maven then adds the dependency to our project.
主站蜘蛛池模板: 清水河县| 雷山县| 永春县| 临澧县| 平湖市| 察哈| 资源县| 米泉市| 桃源县| 德钦县| 肃宁县| 崇阳县| 库伦旗| 龙岩市| 炎陵县| 子长县| 景泰县| 梅河口市| 三亚市| 晋宁县| 丰原市| 灵丘县| 武冈市| 石棉县| 门源| 丰台区| 高平市| 芒康县| 克拉玛依市| 嘉善县| 佳木斯市| 阜南县| 和林格尔县| 峨山| 玉屏| 宣汉县| 长兴县| 安远县| 敦化市| 桦川县| 同德县|