[英]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.