PrimeFaces setup with Maven and Tomcat

In this post, we will setup PrimeFaces 5.3 with Maven and Tomcat. It is assumed that the installations described in this post are already in place.  

Maven Archetype
Use Maven webapp Archetype to create application structure

Create Folders
Create folders src/main/java, src/test/java and src/test/resources.

Update pom.xml

There are optional dependencies for specific features/components, which can be added as needed (E.g. commons-fileupload and commons-io for FileUpload feature). Similarly, other dependencies like Hibernate/JPA, Spring etc. can be added as the application development progresses, as needed.

Add plugin specifying java version (as desired) inside <build>:

Update web.xml

Import Maven Project into Eclipse

Open Eclipse with C:\tvi\Software\workspace_mars as workspace directory. File –> Import –> Existing Maven Projects. Root Directory C:\tvi\Software\workspace_mars\PrimeFacesWebAppLab. Select PrimeFacesWebAppLab’s pom.xml

Create test xhtml file and Managed bean

In Eclipse project explorer, go to src\main\webapp. Right-click –> New –> xhtml page. Give file name as helloworld.xhtml.

In Project explorer, go to src\main\java. Right-click –> New –> Other –> Class. Give package name as com.techvalueinsight.jsf.primefaces and class name as HelloWorld.

Deploy on Tomcat from Eclipse

Start Tomcat from the Servers tab

image

Right-click on the server –> Add And Remove –> Select PrimeFacesWebAppLab

Access the application from browser

image

Give a name and click Submit:

image

Leave a Reply

Your email address will not be published.