Skip to main content


developerWorks  >  Java technology | Web development  >

Introduction to Spring 2 and JPA

Explore the Spring 2 framework and the Java Persistence API with Eclipse and DB2 Express-C

developerWorks

Level: Intermediate

Sing Li (westmakaha@yahoo.com), Author, Wrox Press

08 Aug 2006

Register now or sign in using your IBM ID and password.

Java™ server applications need not be difficult and tedious to create. Now in its second generation, the lightweight Spring framework adds a large suite of features that make it simple for even new server application developers to use. One key enhancement is Spring 2's integration with the Java Persistence API (JPA), a cornerstone of the Enterprise JavaBeans (EJB) 3.0 specification. In this tutorial, learn how to create server applications from scratch using the Spring 2 framework.

In this tutorial

This tutorial aims to guide you through the use and application of the Spring 2 framework in the shortest possible time using a pure and simple learn-by-coding approach. You will build a Web application from scratch, step by step, assisted by the Spring 2 framework.

This tutorial does not attempt to cover all of Spring 2's features and options. Instead, it focuses narrowly on one proven approach to server application development using Spring.

You will proceed through a complete "from concept to application" cycle, including:

  • Performing domain analysis

  • Coding business objects and services

  • Unit testing of business objects

  • Adding data access code painlessly to business objects using Spring JPA

  • Implementing your services using Spring DAO (data access object)

  • Coding integration tests for your services against DB2 Express-C

  • Creating controllers for a Spring Model-View-Controller (MVC) based user interface

  • Designing views for the user interface

  • Creating a deployable WAR file of your application

  • Configuring and deploying your application on the Apache Tomcat server

By the end of the tutorial, you'll understand how the Spring 2 framework works and how it can help you create highly componentized and maintainable Web applications. You'll gain working experience in building such an application and can apply many of the techniques you learn here to your daily development tasks.


Prerequisites

  • You should be familiar with basic object-oriented design concepts and Java development using Java SE 5, including generics. Relational database concepts should be familiar to you, and you should have basic knowledge of how to set up a new database in DB2 Express-C.
  • Familiarity with testing terminology, including unit testing and integration testing, is assumed. Working experience with test frameworks such as JUnit is desirable, but not required.
  • You should have working experience with Eclipse and be able to create new Java projects, compile Java code, and debug projects within Eclipse.

System requirements

The required hardware configuration for trying out the tools and example in this tutorial is a system with at least 512 MB of memory (1 GB recommended).

You need the following software installed:

  • Sun's JDK 5.0_Update 7 or later, or a version of the IBM Developer Kit for the Java 5 platform.
  • Spring framework 2.0. The code in this tutorial has been tested with Spring 2.0 RC 2. Select the "with-dependencies" version of the distribution. This will save you many additional downloads from different sites, because it contains many of the required open source project binaries.
  • A version of the Tomcat 5.5 server. Choose the ZIP file download for the server and unarchive it into a directory of your choice.This tutorial's code has been tested against Tomcat 5.5.17.
  • DB2 Express-C (version 8.2.4 or later).
  • Eclipse 3.2 or later, including the Web Tools Platform (WTP) 1.5 or later.
  • The JPA reference implementation. Follow the full installation instructions in Writing DAO integration tests against an RDBMS in this tutorial.


Duration

2 hours


Formats

html, pdf


Share this....

digg Digg this story del.icio.us del.icio.us Slashdot Slashdot it!


Back to top


Document options

Document options requiring JavaScript are not displayed