Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Java 9 Dependency Injection

You're reading from   Java 9 Dependency Injection Write loosely coupled code with Spring 5 and Guice

Arrow left icon
Product type Paperback
Published in Apr 2018
Publisher Packt
ISBN-13 9781788296250
Length 246 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Nilang Patel Nilang Patel
Author Profile Icon Nilang Patel
Nilang Patel
Krunal Patel Krunal Patel
Author Profile Icon Krunal Patel
Krunal Patel
Arrow right icon
View More author details
Toc

Introduction to bean scopes in Spring


In Chapter 3, Dependency Injection with Google Guice, we learned about different Spring modules along with dependency injection. In Spring, beans are the backbone of an application, and they are managed by a Spring IOC container. A bean is a class or object that is created using the configuration of metadata that we can pass to an IOC container. Before learning about scope, let's define a bean in Spring.

Bean definition 

The metadata of a bean has its own properties with independent bean definitions. Some of these bean definitions are as follows:

  • Class: This will be used to create a bean, and it is mandatory to mention a class name for which we are supposed to create a bean.
  •  Name: If we want to define different aliases for the bean, then we use the nameattribute, with the help of a separator, such as a comma (,) or semicolon (;). When we have XML-based configuration, we can use the name and/oridattribute as an identifier for a bean. A bean with an id attribute...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime