Bean
Bean
- A bean is a Java object managed by the Spring IoC container
- Bean Definition Type
- XML Configuration
- Define beans in
applicationContext.xml
- Define beans in
- Annotation-Based Configuration
- Define beans by using annotations like
@Component
on classes
- Define beans by using annotations like
- Java Configuration
- Defines beans in
@Configuration
classes and@Bean
methods
- Defines beans in
- XML Configuration
- Bean Scope
- Singleton (Default)
- eg. logging service
- Prototype
- eg. order processor
- Request
- eg. user preferences
- Session
- eg. shopping cart
- Application
- eg. cache
- WebSocket
- eg. order tracking
- Singleton (Default)