【发布时间】:2020-03-21 06:09:45
【问题描述】:
假设我们有一个类
@RequestScope
public abstract class A {
int a;
}
以及扩展上述类的另一个类
@Service
public class B extends A {
public int getA () { return a; }
}
这个类 B 的变量(它从 A 扩展而来)是请求范围的变量吗?
UPD
我正在查看 spring 代码,它说
/** * Constant for the default scope name: {@code ""}, equivalent to singleton * status unless overridden from a parent bean definition (if applicable). */ public static final String SCOPE_DEFAULT = "";
还有,
((AbstractBeanDefinition)((AnnotationConfigEmbeddedWebApplicationContext) ctx).
getBeanDefinition("b")).scope
返回"singleton"
但如果我用 @RequestScope 标记 B 类,则此属性将更改为 ""
我假设又是sigleton
【问题讨论】:
标签: spring spring-boot inheritance spring-annotations requestscope