Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在zk中创建session=scope的Springbean时出错_Spring_Mvvm_Spring Security_Inversion Of Control_Zk - Fatal编程技术网

在zk中创建session=scope的Springbean时出错

在zk中创建session=scope的Springbean时出错,spring,mvvm,spring-security,inversion-of-control,zk,Spring,Mvvm,Spring Security,Inversion Of Control,Zk,在应用程序上下文中 <beans:bean id="Facade" class="com.facade.Facade"/> 我得到下面的错误。。。。如何修复它? 我正在使用zk+spring-security [java] Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'F acade': Scope

在应用程序上下文中

    <beans:bean id="Facade"
      class="com.facade.Facade"/> 
我得到下面的错误。。。。如何修复它? 我正在使用
zk
+
spring-security

     [java] Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'F
acade': Scope 'session' is not active for the current thread; consider defining a scoped proxy for this bean if you inte
nd 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? If you are actually operating within a web req
uest and still receive this message,your code is probably running outside of DispatcherServlet/DispatcherPortlet: In thi
s case, use RequestContextListener or RequestContextFilter to expose the current request.

你的评论对于解决方案来说确实是正确的。 但是为什么您希望一个facade在会话范围内呢

换句话说,您将为每个会话一次又一次地创建这个bean。 因此,如果有5个用户登录,您就有5个相同类的bean
这仍然是通缉犯的情况吗


Greetz chill.

解决了问题您是对的。。它不应在会话范围内。。。我只是在测试zk会话范围
     [java] Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'F
acade': Scope 'session' is not active for the current thread; consider defining a scoped proxy for this bean if you inte
nd 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? If you are actually operating within a web req
uest and still receive this message,your code is probably running outside of DispatcherServlet/DispatcherPortlet: In thi
s case, use RequestContextListener or RequestContextFilter to expose the current request.