Spring Bean Scopes and Lifecycle
Last Updated on: August 1, 2021 pm
Spring Bean Scopes and Lifecycle
Bean Scopes
1 |
|
Singleton - Default
- The Spring Container only creates only one instance of the bean.
- It’s cached in memory.
- All requests for the bean - will return a shared reference to the SAME bean.
Prototype
Creates a new bean instance for each container request.
Bean Lifecycle
Custom methods
Defining init and destroy methods
Configure the method names in Spring config file
Reference: Udemy, Spring & Hibernate for Beginners (including SpringBoot)