Spring系列——@Scope
前言
此文会以用户的购物车为例,来讲解~
了解过SpringXml形式开发的同学,一定都知道scope的标签的使用。
<bean id="cart" class="pers.weini.bean.ShoppingCart" scope="session"/>
@Scope注解的功能和这个scope标签是一样的——定义Bean的创建模式。
@Scope源码
@Target({
ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Scope {
@AliasFor("scopeName")
String value()