Scopes

On this journey, we've learned dependency injection concepts in Java 9, Spring, and Google Guice, with the help of examples.

In Chapter 3Dependency Injection with Spring, and Chapter 4Dependency Injection with Google Guice, we came across the word scope, which is a very important element of Spring beans and Google Guice. So, let's understand what a scope is, and why it is important when talking about dependency injection.

In this chapter, we will first learn about various scopes provided by Spring, and how they can be defined for Spring beans. We will also learn the relation between bean scope and dependency injection. Finally, we will look into the scopes available in Google Guice. The topics we are going to cover are as follows: ...

Get Java 9 Dependency Injection 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.