Creating a Spring 3 web MVC project from scratch

So, you heard all about Spring and how it is a lightweight Java framework for developing enterprise (or smaller) applications and how it can do or facilitate a ton of things for you, like dependency injection, aspect oriented programming, providing and MVC programming structure and security. Good! Because in this tutorial I am going to explain how to set up a simple project with Spring, Maven and Eclipse and I am only going to explain the technologies very briefly here before starting on the actual project. If you need more background on the technologies used here, please use the links under each description below.

Project technologies

I will show you how to create a small application that can store and retrieve courses from a database. We will be using the following technologies.


tomcat it is an implementation of the Java Servlet specification. It is an application server that runs Java web applications.

More on Tomcat:


Maven is a software project management tool for developers that is widely adopted in the Java community. Developers use it to declaratively (in XML) specify which external libraries their projects depend on. These libraries are the automatically downloaded and added to your project by Maven. Maven can also compile, builld and deploy your project.

More on Maven:

Spring 3

You probably already know what Spring is, but for clarity's sake: it is a large Java framework. Large in the sense that it can do a lot. But it is also lightweight in the sense that it doesn't take up a huge amount of resources, it is small size and it (usually) doesn't require coders to write Spring-specific methods or extend Spring-specific classes, keeping your code clean and loosely coupled. 

Spring was developed as a response on the JEE (Java Enterprise Edition) specification, that is widely regarded as being quite obstrusive. JEE code is often tightly coupled to the JEE packages. Java EE classes you build must implement extra methods or extend JEE framework classes in order to function within the JEE container and this couples them to the JEE libraries, making it impossible to use them outside of the JEE realm. 

More on Spring:

Spring MVC

Model-View-Controller (MVC) is a programming pattern. The Model (in a web application) is 'data', usually from a database. This is the stuff you want to write to the database, show on the screen or make calculations with.

The View is obviously the.... view, the part of the application that generates he webpage you want to show information (the model) on. JSP is the de facto view technology used in Spring MVC. I assume you know JSP. If not:

mvc pattern

The final part of MCV, the Controller, sits between the view and the model. It controls the application flow. It receives requests for specific resources (a webpage for example), initiates actions like getting data (model) from a database or from a web service and it returns data to the view for display. The controller really controls what 'happens' in an application.

So, Spring MVC is just one implementation of the popular MVC programming paradigm. A lot of programming languages have one or more MVC frameworks.


For that one person that bumped in here and doesn't know yet: Eclipse is an IDE, and Intergrated Development Environment. It is popular in the Java community. Probably the most popular and that is why I am going to use it in this tutorial. Personally I like IntelliJ better, because that is what is is, better :) But it's not free.

More on Eclipse: