Introduction
Once again, this article is also a continuation from the previous article. The previous one is focusing on how to add JSF library to the maven-based Java web application. That article is an article with the title of ‘How to Add JSF Library to a maven-based Web Application in NetBeans IDE’ and it exist in this link. But on this article, it will focus to add a Primefaces library to the maven-based Web Application in NetBeans IDE. Primefaces itself, according to the official webpage available in this link, claimed itself as a leading provider of open source UI component libraries. It is a perfect compatible companion as an UI component libraries for technology such as Angular, React, Vue and JSF. It provides lots of elegant, high-performance, accessible and fully customizable UI Components.
How to Add Primefaces Library to a maven-based Web Application in NetBeans IDE
So, after successfully adding JSF framework to the maven-based Java web application, the following is the step for adding the Primefaces library to a maven-based Java web application :
-
The first step as usual, just run the NetBeans IDE. It is obvious since in this context, it is using NetBeans IDE to develop the Java web application.
-
After that, open the pom.xml file which a file act as a project descriptor file. It is very useful to define libraries which the Java web application depend on it. By defining it, maven tool will read and download the necessary library exist in the dependency section exist in the ‘pom.xml’ file. It exist as in the following image :
-
Next step, just search in the maven repository for Primefaces library definition in maven file descriptor, ‘pom.xml’ file. The webpage address of the maven repository currently is in this link. After searching it using the filter search available in the webpage, the following is the newest version of the Primefaces library available for further definition in the ‘pom.xml’ file :
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.mycompany</groupId> <artifactId>webapp</artifactId> <version>1.0-SNAPSHOT</version> <packaging>war</packaging> <name>webapp-1.0-SNAPSHOT</name> <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <failOnMissingWebXml>false</failOnMissingWebXml> <jakartaee>8.0</jakartaee> </properties> <dependencies> <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>${jakartaee}</version> <scope>provided</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> <compilerArguments> <endorseddirs>${endorsed.dir}</endorseddirs> </compilerArguments> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>3.3.2</version> <configuration> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>3.3.0</version> <executions> <execution> <phase>validate</phase> <goals> <goal>copy</goal> </goals> <configuration> <outputDirectory>${endorsed.dir}</outputDirectory> <silent>true</silent> <artifactItems> <artifactItem> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>${jakartaee}</version> <type>jar</type> </artifactItem> </artifactItems> </configuration> </execution> </executions> </plugin> </plugins> </build> </project>
-
Just add the following definition of Primefaces library to the ‘pom.xml’ file.
<!-- https://mvnrepository.com/artifact/org.primefaces/primefaces --> <dependency> <groupId>org.primefaces</groupId> <artifactId>primefaces</artifactId> <version>11.0.0</version> </dependency>
So, the overall definition in the dependencies section will be as follows :
<dependencies> <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>${jakartaee}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.primefaces</groupId> <artifactId>primefaces</artifactId> <version>11.0.0</version> </dependency> </dependencies>
- Do not forget to build and compile the Java web application once more. After adding the Primefaces library to the Java web application.
2 thoughts on “How to Add Primefaces Library to a maven-based Java Web Application in NetBeans IDE”