Spring Jasper Report with Maven. Example to convert web application to maven based in Eclipse.

This tutorial is a continuation of my old tutorial that is to generate dynamic reports from database using Jasper Reports in Spring 4 mvc. The example project (SpringJasperDemo) used in that tutorial was developed without maven support. Here we will see how to develop the same project with maven support. Instead of rewriting the same tutorial again, we will see here how to convert the same project into maven based. This can be done in two ways.

I) Option 1:

1. Check out the old project (SpringJasperDemo without maven) using github repository
https://github.com/vkjegan/SpringJasperDemo

1. You can convert the exisiting project by right clicking on the project and select   Configure ->Convert to Maven Project

spring jasper maven

2. Fill the Artifact details like Group Id, Artifact Id, etc..

spring jasper maven11

3. Click on Finish. Now the project is converted to maven based and the new project structure is given below.

Project Structure:

spring jasper maven project structure

2. Replace the content of pom.xml file with the content of pom.xml given below.

For java code, XML template and steps, please visit my old tutorial

Now we will see the pom.xml to develop the same project using maven.

pom.xml

II) Option 2:

1. Create a new maven based dynamic project by selecting File-> New->Other->Maven->Maven Project

spring jasper maven new

spring jasper maven new1

2. Select Next

3. Select Workspace location where the project to be created and Next

4. Select an Archetype as webapp

spring jasper maven new2

5. Fill the details like GroupId, ArtifactId, etc.. and FInish

spring jasper maven11

6. Copy the necessary source code, JSP, xml files from the old tutorial by creating necessary packages & folders

7. Replace the pom.xml file with the content of above pom.xml. If required add the below lines also in pom.xml for servlet api dependency.

8. Update the Maven Project by right clicking on the project and Select Maven->Update Project

spring jasper maven new4

9. Include Maven Dependencies in the Deployment Assembly by  right clicking on the project and Select properties->Deployment Assembly

Add ->Java Build Path Entries -> Maven Dependencies and Finish & Ok.

spring jasper maven new5

 

 

Project Structure:

spring jasper maven project structure new

10. Compile and run the project by calling the URL

http://localhost:8080/<project Name>/loadJasper.do

Note: # This maven project is tested with Application Server Tomcat Apache 8

You can download the example project with source code at 

 also you can check out the project from  github.com.  Git URL:  https://github.com/vkjegan/SpringJasperMaven

For checking out the git repository, please visit my earlier post

How to share eclipse project to github and viceversa

 

You may also like

Leave a Reply