reset password

Spring and Hibernate From Scratch

In this guide I will describe the process to create a Spring and Hibernate web application from scratch - or actually, almost from scratch as we will start with a simple Maven project created using Eclipse.

Before we begin, let me first point out that the easiest way to create a Spring/Hibernate project is to use a Maven archetype, and there are a whole bunch of these archetypes out there. The problem is that there are many different ways to set up a Spring/Hibernate project (there's a reason why there are so many different Spring/Hibernate archetypes), and it is pretty hard to find an archetype that does things in exactly the way you want. Even if you do find such a perfect archetype (which I may create sometime in the future), you still need to understand the project structure and the configuration files because chances are you'll need to change them during development, and this is the reason why I think a guide like this is very helpful.

We will use a sample project called springmvc to illustrate the process. The project name will appear in various configuration files, and needless to say you should change it to the name of your project. The software we will be using is Eclipse for Java EE Developers with a few additional plugins as described here. We assume that the application server is Tomcat 7 (or anything supports Servlet 3.0 Specification), and the DBMS is PostgreSQL (or anything supported by Hibernate). We will divide the process into several steps: we first create an Maven web project, then add Spring MVC, Hibernate, TestNG, and Spring Security. The source code of springmvc is available at svn://sun.calstatela.edu/cs520/springmvc - under /trunk is the complete project, and under /tags you can find the project after each step.

1. Maven Web Application

2. Spring MVC

3. Hibernate

4. Testing

5. Spring Security

This page has been viewed 38519 times.