spring bean
时间: 2023-09-14 22:13:09 浏览: 134
A Spring bean is a Java object that is managed by the Spring framework. It is a fundamental building block of a Spring application and can be configured and wired together in various ways to form the application's functionality.
Spring beans are typically defined in XML configuration files or using annotations, and they can be instantiated, configured, and managed by the Spring container at runtime. The Spring container is responsible for creating, initializing, and managing the lifecycle of Spring beans.
Spring beans can be scoped, meaning that they can have a specific lifetime and visibility within the application context. The most commonly used scopes are singleton, prototype, request, session, and global session.
Spring beans can also be wired together using dependency injection, which is a technique for managing object dependencies by injecting them into the dependent object rather than having the dependent object create them itself. This promotes loose coupling and makes the application more modular and testable.
阅读全文