Chapter 16

The Spring Framework

The Spring Framework is designed to be a lightweight, non-intrusive framework, providing you with tools and facilities to write standalone, testable components for use in many common applications and scenarios.

Spring enables you to write Plain Old Java Objects, or POJOs, and then connect them together using dependency injection, through a central core component called the application context. POJOs are classes that have no unnecessary restriction, such as implementing an interface for a persistence framework, or extending an abstract class for use in a web application.

The notion of POJOs comes as a reaction from the early approaches to Enterprise Java Beans (EJBs), where your simple domain object needed to follow complicated patterns and implement several interfaces in order to be used within application servers. This code was often brittle and untestable. In turn, this led to a rise in popularity of frameworks such as Spring, which concentrated on simple approaches around application configuration and focused on writing testable code.

This chapter covers several core areas of the Spring Framework: the application context, database programming with the JdbcTemplate, the integration testing classes, and a section on producing web applications using Spring MVC.

Core Spring and the Application Context

How do you use dependency injection with Spring?

Chapter 9 showed a brief example of what dependency injection is, and what advantage it gives. ...

Get Java Programming Interviews Exposed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.