Lesson 36Working with the Spring Framework

Spring is a collection of libraries that provide support for JVM-based enterprise applications. We will use the Spring framework portion of the larger Spring ecosystem in this lesson. The Spring framework provides support for dependency injection, MVC web applications, RESTful web services, authentication/authorization, and database connectivity.

In this lesson, we will look at dependency injection with Spring and how to accomplish it using XML configuration files or annotation-based configuration.

DEPENDENCY INJECTION AND PROGRAMMING TO INTERFACES

As we have covered in previous lessons, dependency injection is a design pattern that implements a form of inversion of control. In fact, these two terms are used interchangeably.

The “inversion” of control in this case is that client objects are no longer responsible for instantiating the objects (also known as services) on which they depend. Instead, the dependencies are handed to (i.e., injected into) the client objects by some other entity. Dependencies are handed to the client through either constructors or setter methods. ...

Get Job Ready Java 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.