Enterprise Java

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.

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.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

4 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Rami Tayba
Rami Tayba
11 years ago

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

crowgun
crowgun
10 years ago

How can i set up this project in Eclipse?

Mihaly Szakszon
8 years ago

Hi,

I have a similar project for java SE dev. teams:
https://develosapiens.wordpress.com/java-project-environment-deployer-system/

Kamesh Rao Yeduvakula
8 years ago

Spring AngularJS Java WebApp Template Project Now bringing you the much needed and long pending update to my previous Java Web App Template that I was trying to put together for quite some time now where I am showcasing a template project that can be taken as is to begin developing a modern AngularJS web app backed by Spring and Java. The projects brings together Java, Spring 4, Spring MVC 4, Spring JPA, Hibernate, Angular JS, Twitter Bootstrap, JWT Token Authentication technology in a clean easy to use and bootstrap fashion. Download and start building your next big thing in… Read more »

Back to top button