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:

  • Introduction to bean scopes in Spring
  • How to define a bean scope
  • Dependency injection and bean scopes
  • How to choose a bean scope
  • Scopes in Google Guice
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.27.251