Spring Service默认范围 [英] Spring Service default scope

查看:118
本文介绍了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)?

推荐答案


Spring 4 @Service的默认范围是什么?

Which is the default scope of a Spring 4 @Service?

默认范围是单例


设计一个Service实现以便存储与当前登录用户相关的一些信息是合理的(根据当前的HTTP会话)

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)

是的。在这种情况下,服务必须具有范围会话。请参阅 http: //docs.spring.io/spring/docs/current/spring-framework-reference/html/beans.html#beans-factory-scopes-other

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默认范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆