How should I inject dependencies in Spring?

Learn Spring’s three dependency injection methods and understand when to use them.

By Kevin Bowersox
March 3, 2017
Screen from "How should I inject dependencies in Spring?" Screen from "How should I inject dependencies in Spring?" (source: O'Reilly)

Dependency injection is at the core of the Spring framework and recognizing it in all of its forms is important when reading source code. In this video, Kevin Bowersox introduces three approaches to dependency injection in Spring: field injection, setter injection, and constructor injection. Using the Spring Tool Suite, Spring beginners will learn the advantages and disadvantages of each approach in a variety of situations.

Upgrade your skills with Building Microservices with Spring.

Learn faster. Dig deeper. See farther.

Join the O'Reilly online learning platform. Get a free trial today and find answers on the fly, or master something new and useful.

Learn more

Kevin Bowersox has built Java web applications for the past eight years. Completing his master’s degree at the University of Pennsylvania, Kevin adopted modern frameworks such as Spring and Hibernate as his main specialties. Kevin now leads a team of developers, and has developed several frameworks for use by internal development teams.

Post topics: Software Engineering