About Kamesh Rao

Kamesh is a Software Development Engineer at Amazon.com working in Advertising and Payments domain. He has extensive experience in web and mobile platform and applications development with hands on experience in Java, C++, Ruby, Scala, Objective-C among others.

Maven Web Project Kickstarter Codebase with Spring, Hibernate, Akka, Twitter Bootstrap, Apache Tiles and jQuery

I am happy to upload my second project to GitHub to help people get started with Java Web App Development as quickly as possible. I am sharing this code with Apache License 2.0. Here is the URL for the same:

https://github.com/ykameshrao/spring-hibernate-springdata-springmvc-maven-project-framework

The project consists of following parts:

1) Commons-Deps: Dependencies declared as a single pom file to easily manage the project dependencies. It is upto personal choice of users to still continue have it this way or go with their own chosen method to manage dependencies in maven pom.

2) Commons: A lot of common code snippets are provided as part of commons jar module to help send mails using gmail, java mail, utf8 encoding, JCS cache managers, session managers, random string, etc.

3) Framework: This part of the code base includes JPA and Spring Data Entities, JPA and Spring Data Repositories, Services which are built using Java Generics to help provide the CRUD actions on these Entities when users build their own domain specific entities, repositories and services extending the ones provided here. It also contains, API and Web App Controllers providing basic functionality again for people interested in building their own Spring MVC controllers using these. Also, contained here are validators, exceptions, AOP based exception handlers.

4) Your Own Web App Code: This part of the code provides a bootstrapped web project with API and Web UI using the best practices I picked across time to do things using the third party frameworks, libraries I have chosen here. The API parts is configured to accept and generate both XML and JSON request and response formats. Akka is also configured here to present the method in which it can be used to offload activities from your Spring MVC controllers (Servlets). Here it is programmed to offload the task of sending emails.

This is the wrapper framework laid out to start building Spring based Web apps with Hibernate ORM layer or Spring Data ORM powered NoSQL and Spring MVC in Java programming language. The purpose of this project is to get you started quickly in Java web app development over a widely used and tested Java web development infrastructure.

This project provides sample hibernate entities, spring data entities, akka actors to offload mail sending like jobs, models, repositories, services and controllers classes. There are also many framework level classes to help handle exceptions and errors in the project you may start developing using this. The UI for the default simple web project bundled in this framework is built using Twiiter Bootstrap, Apache Tiles, jQuery, jQuery Validation, JSPs.

I can try my best to provide with as much detail as possible here, but the best way to understand all that is provided is by reading the code. Therefore, I also provided a sample web app project with functionality to register and login a user. All the code is presented in a package structure that can be renamed as per your own choice and requirements. Enjoy!

Configurations config/props/mail.properties

mail.transport.protocol=smtps
mail.host=smtp.gmail.com
mail.user=
mail.pass=
mail.port=465
mail.starttls=true
mail.auth=true
mail.debug=true
mail.fromAddress=

config/props/database.properties

 
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/yourwebprojectdb
jdbc.username=
jdbc.password=
hibernate.c3p0.min_size=5
hibernate.c3p0.max_size=20
hibernate.c3p0.timeout=600
hibernate.c3p0.max_statements=50

src/main/resources/tiles/templates.web.xml

 
<?xml version=”1.0” encoding=”UTF-8” ?>
<!DOCTYPE tiles-definitions PUBLIC
”-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN”
”http://tiles.apache.org/dtds/tiles-config_2_0.dtd”>
 
<tiles-definitions>
 <definition name=”base” template=”/WEB-INF/views/layout/web.jsp”>
  <put-attribute name=”title” value=”” />
  <put-attribute name=”header” value=”/WEB-INF/views/common/header.web.jsp” />
  <put-attribute name=”message” value=”/WEB-INF/views/common/message.web.jsp” />
  <put-attribute name=”content” value=”” />
  <put-attribute name=”footer” value=”/WEB-INF/views/common/footer.web.jsp” />
 </definition>
      
 <definition name=”home” extends=”base”>
  <put-attribute name=”title” value=”Your Web Project” />
  <put-attribute name=”content” value=”/WEB-INF/views/web/home.web.jsp” />
 </definition>
      
 <definition name=”userRegistration” extends=”base”>
  <put-attribute name=”title” value=”Register” />
  <put-attribute name=”content” value=”/WEB-INF/views/web/userRegistration.web.jsp” />
 </definition>
      
 <definition name=”dashboard” extends=”base”>
  <put-attribute name=”title” value=”Dashboard” />
  <put-attribute name=”content” value=”/WEB-INF/views/web/dashboard.web.jsp” />
 </definition>
      
 <definition name=”error” extends=”base”>
  <put-attribute name=”title” value=”Error” />
  <put-attribute name=”content” value=”/WEB-INF/views/web/error.web.jsp” />
 </definition>
</tiles-definitions>

Startup VM Options Required

-Dconf.path=”path-to-config-folder-on-target-machine-containing-property-files”

Refer: src/main/resources/config/spring/applicationContext-properties.xml

     
<util:properties id=”mdbProps” location=”file:#{systemProperties[‘conf.path’]}/config/props/mongodb.properties” />
<util:properties id=”dbProps” location=”file:#{systemProperties[‘conf.path’]}/config/props/database.properties” />
<util:properties id=”logProps” location=”file:#{systemProperties[‘conf.path’]}/config/props/log4j.properties” />
<util:properties id=”amProps” location=”file:#{systemProperties[‘conf.path’]}/config/props/api.messages.properties” />

      :

      :
 

Screenshots

 
The frameworks strung together supporting multiple activities in this framework layer of code are – 

Maven Java 1.7 
Spring 3.1.1 
Hibernate 4+ 
Spring Data 
MongoDB 
Akka 1.3+ 
Apache Tiles 2+ 
Twitter Bootstrap 2+ 
Velocity for Mails 
BootSwatch 
jQuery

Reference: Spring, Hibernate, Spring Data, Akka, Twitter Bootstrap, Apache Tiles, jQuery powered Maven Java Web Project Kickstarter Codebase from our JCG partner Y Kamesh Rao at the OrangeApple blog.

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

JPA Mini Book

Learn how to leverage the power of JPA in order to create robust and flexible Java applications. With this Mini Book, you will get introduced to JPA and smoothly transition to more advanced concepts.

JVM Troubleshooting Guide

The Java virtual machine is really the foundation of any Java EE platform. Learn how to master it with this advanced guide!

Given email address is already subscribed, thank you!
Oops. Something went wrong. Please try again later.
Please provide a valid email address.
Thank you, your sign-up request was successful! Please check your e-mail inbox.
Please complete the CAPTCHA.
Please fill in the required fields.

2 Responses to "Maven Web Project Kickstarter Codebase with Spring, Hibernate, Akka, Twitter Bootstrap, Apache Tiles and jQuery"

  1. Rami Tayba says:

    Great, can you provide a version with hibernate annotation.
    Thank you

  2. crowgun says:

    How can i set up this project in Eclipse?

Leave a Reply


three × = 6



Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy | Contact
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
Do you want to know how to develop your skillset and become a ...
Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

Get ready to Rock!
You can download the complementary eBooks using the links below:
Close