The bean's scope
Spring provides us with beans after instantiating and configuring them. Spring Container manages objects. This means that any object can refer to any other object from Spring Container using the bean's ID, and Spring Container provides an instance of the requesting object.
When we start Spring Container, ApplicationContext
reads the Spring configuration, file looks for all bean definitions available there, and then initializes beans before any call to the getBean()
method.
During initialization, ApplicationContext
itself has initialized all the Spring beans configured in Spring XML. When another object makes a call to the getBean()
method, ApplicationContext
returns the same reference of bean that has already been initialized. This ...
Get Spring: Developing Java Applications for the Enterprise 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.