table of contents

The Spring Framework: A Tutorial

Interested in training from the author of these tutorials? See the upcoming Spring & Hibernate/JPA courses in San Francisco and Maryland, or contact hall@coreservlets.com for info on customized courses at your location.


This tutorial is divided into two main sections. Section 1 is written by Marty Hall and provides an easy-to-understand tutorial for Spring beginners. If you are new to Spring or care only about the core Spring capability of defining beans and dependency injection (inversion of control), this is the section for you. This section is used as part of the coreservlets.com servlet and JSP training courses or as a one-day standalone training class on Spring basics.

Section 2 is written by Kyong Park and provides a fast-moving tutorial that covers many different Spring capabilities and modules. If you are familiar with the basics of Spring, or are going to be using Spring extensively in your applications, this is the section for you. The detailed Spring training course, on which this section is based is usually taught on-site at customer locations, but various Java EE training courses at public venues are periodically scheduled for people with too few developers for an onsite course. For descriptions of the various other courses that are available, please see the J2EE training course page. To inquire about a customized training course at your location, please contact Marty at hall@coreservlets.com.

If you find these free tutorials helpful, we would appreciate it if you would link to us.

Source Code

Source code for all examples in this tutorial can be downloaded from the Spring sample code repository.

PowerPoint Files for University Faculty

The PDF files in this tutorial contain the complete text of the original PowerPoint files, so if your goal is learning Spring, just stick with this tutorial. However, as a service to instructors teaching full-semester courses at accredited universities, coreservlets.com will release the original PowerPoint files for free. Please see the instructor materials page for details.


Section 1: Spring Basics


The Spring Framework: Overview and Setup

Tutorial section:

Topics:

  • What is Spring?
    • And why use it?
  • Main Spring modules
    • Dependency injection
    • AOP
  • Configuring apps to use Spring
    • And Eclipse plugin support
  • Simple example

Source code:

  • spring-intro.zip. Sample code used in this section, bundled as an Eclipse project.
  • spring-blank.zip. Basic starting point for Spring apps: an Eclipse project with the required JAR files, a blank applicationContext.xml, the Spring IDE project nature, and nothing else. Copy and rename this when you start new Spring-based apps.

The Core Spring Module: Defining Beans and Dependency Injection

Tutorial section:

Topics:

  • Setting bean properties
  • Supplying constructor arguments
  • Using factory methods
  • Dependency injection
    • Supplying other beans as properties or constructor args
  • Bean scopes

Source code:

Using Spring in Web Apps and JSF

Tutorial section:

Topics:

  • Servlet/JSP apps
    • Creating a Dynamic Web Project in Eclipse
    • Adding Spring support
    • Adding Spring JAR files and bean definition file
    • Registering listeners in web.xml
    • Loading bean definition file
    • Getting bean instances
  • JSF apps
    • Creating a JSF Project in Eclipse
    • Adding Spring support
    • Defining beans in applicationContext.xml
    • Defining beans in faces-config.xml

Source code:


Section 2: Spring in Detail


The Spring Framework: Foundations

Tutorial section:

Topics:

  • Motivation
  • Spring Hello World
  • POJO development
  • Runtime environment
  • Dependency injection
  • Inversion of control

Source code:

  • spring-foundations.zip. Sample code used in this section, bundled as an Eclipse project.
  • spring-blank.zip. Basic starting point for Spring apps: an Eclipse project with the required JAR files, a blank application-context.xml, and nothing else. Copy and rename this when you start new Spring-based apps.
  • spring-blank-extended.zip. Beefed-up starting point for Spring apps: an Eclipse project with the required JAR files, various optional JAR files, JAR files of the source code, a blank application-context.xml, and several sample setup and configuration files.

The Spring Framework: Core Capabilities Part 1

Tutorial section:

Topics:

  • Spring IoC container
  • Interface-oriented development
  • Spring framework composition
  • Spring container instantiation
  • Spring bean definitions

Source code:

The Spring Framework: Core Capabilities Part 2

Tutorial section:

Topics:

  • Bean naming
  • Bean scoping
  • Dependency injection

Source code:

The Spring Framework: Core Capabilities Part 3

Tutorial section:

Topics:

  • Referencing other beans
  • Plain values
  • Properties integration
  • Resource integration
  • Collection mapping

Source code:

Spring JDBC Part 1

Tutorial section:

Topics:

  • Introduction to Spring JDBC
  • Spring JDBC development
  • Spring IoC integration

Source code:

Spring JDBC Part 2

Tutorial section:

Topics:

  • Introduction to Spring JDBC APIs
  • Result transformations
  • Parameter mapping
  • Updating tables

Source code:

Aspect-Oriented Programming (AOP) with Spring, Part 1

Tutorial section:

Topics:

  • Aspect-oriented programming concepts
  • Introduction
  • Integration with Spring IoC
  • Program integration using pointcuts

Source code:

Aspect-Oriented Programming (AOP) with Spring, Part 2

Tutorial section:

Topics:

  • Implementing aspect behavior
  • AspectJ APIs and annotations
  • Spring AOP application

Source code:

Spring Integration Part 1

Tutorial section:

Topics:

  • Maven 2 build system overview
  • General build procedure
  • Multi-module project build process
  • Spring IoC integration
  • Testing with Maven 2 and Spring

Source code:

  • spring-integration.zip. Sample code used in this section. Unlike the code in the previous sections, this code is not bundled as an Eclipse project. Using Maven to turn the code into Eclipse projects is part of what this topic is about.

Spring Integration Part 2

Tutorial section:

Topics:

  • Managing transactions with Spring
  • Creating a transactional test environment
  • Spring and JPA integration
  • Spring, JPA, and JSF integration

Source code:

  • spring-integration.zip. Sample code used in this section. Unlike the code in the previous sections, this code is not bundled as an Eclipse project. Using Maven to turn the code into Eclipse projects is part of what this topic is about.

More Information

Java

JSF (JavaServer Faces)

Servlets & JSP
Ajax, GWT, & JavaScript

Spring, Hibernate, & JPA

Struts