reset password

Spring and Hibernate From Scratch

In this guide I will describe the process to create a minimal Spring and Hibernate web application from scratch - or actually, almost from scratch as we will start with a simple template Maven web 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 an 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 plan to create some time 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 sham (Spring and Hibernate At the Minimum) to illustrate the process. The project name will be used in various configuration files, and we will also use placeholders like foo, bar, or foobar. Needless to say,  when you create your own project, you should replace them with proper values for your project. The software we will be using is Eclipse for Java EE Developers with the Maven plugins m2eclipse and m2e-wtp. We assume that the application server is Tomcat (or anything supports Servlet 2.5 Specification or above), and the DBMS is PostgreSQL (or anything supported by Hibernate). We will divide the process into four step: we first create an Maven web project, then add Spring MVC, Hibernate, and Spring Security.

1. Maven Web Application

2. Spring MVC

3. Hibernate

4. Spring Security

This page has been viewed 38517 times.