[英]Override a spring scope in a child bean
我定义了一个Spring bean,扩展了另一个定义为singleton的bean。 这意味着:
<bean id="aChildBean" parent="aParentBean">
<!-- ......->
</bean>
现在,我想知道是否可以在此bean中定义范围“ request”。 我知道子bean继承了父bean的作用域,但是我不确定这在逻辑上是否可行。 当我对此进行测试时,Spring spring生成了以下异常:
Error creating bean with name 'aChildBean': Scope 'request' is not active for the
current thread; consider defining a scoped proxy for this bean if you intend to refer
to it from a singleton; nested exception is java.lang.IllegalStateException: No thread
bound request found: Are you referring to request attributes outside of an actual web
request, or processing a request outside of the originally receiving thread? ...
因此,我想知道我是否可以执行此操作。 并且,如果定义范围的bean可以解决问题?
预先感谢您的回答。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.