本文介绍了Spring Service默认范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Spring 4 @Service
的默认范围?
设计服务实现以便通过类属性存储与当前登录用户相关的一些信息(根据当前的 HTTP会话)是合理的(也可以使用 final
修饰符)?
It is reasonable to design a Service implementation in order to store some info, related to the current logged user (according to the current HTTP session), through class attributes (also by using the final
modifier)?
推荐答案
默认范围是单例
是的。在这种情况下,服务必须具有范围会话。请参阅
Yes. In that case, the service will have to have the scope "session". See http://docs.spring.io/spring/docs/current/spring-framework-reference/html/beans.html#beans-factory-scopes-other
这篇关于Spring Service默认范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!