开发者

How to fix BeanCreateException for a request scope bean used with Spring MVC framework

开发者 https://www.devze.com 2023-04-11 05:48 出处:网络
I define a bean with scope request and get an error when i start my application: \"Cannot resolve reference to bean \'accountDS\' while setting bean pro开发者_StackOverflow中文版perty \'accountDS\';

I define a bean with scope request and get an error when i start my application:

"Cannot resolve reference to bean 'accountDS' while setting bean pro开发者_StackOverflow中文版perty 'accountDS'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountDS': 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"

I am using this bean from within my controller which is a singleton. Is this why i can't get a request? If so how can i create a scoped proxy? I also have RequestContextListener in my web.xml but it doesn't help.

    <listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>


<bean id="..." class="..." scope="request">
<aop:scoped-proxy />
</bean>
0

精彩评论

暂无评论...
验证码 换一张
取 消