- Mastering Spring 5.0
- Ranga Rao Karanam
- 70字
- 2021-07-02 22:12:06
Spring bean scopes
Spring beans can be created with multiple scopes. The default scope is a singleton.
Since there is only one instance of a singleton bean, it cannot contain any data that is specific to a request.
The scope can be provided with the @Scope annotation on any spring bean:
@Service
@Scope("singleton")
public class BusinessServiceImpl implements BusinessService
The following table shows the different types of scopes available for beans: