A bean scope refers to the lifecycle of a bean. How long the bean lives. How many instances need to be created.
Default scope is singleton.
Spring container creates one instance of bean shared across.
code example
Prototype
Bean Lifecycle:
Spring Container starts beans are instantiated -> dependency Injected -> Internal spring processing -> custom init method -> Bean ready to use -> Application Shut down (custom method to close bean is executed before application shutdown).
Top comments (0)