Spring Service default scope

做~自己de王妃 提交于 2020-01-01 01:14:08

问题


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

Does it make sense designing a Service implementation to store info about the current logged user (according to the current HTTP session), through class attributes (also by using the final modifier)?


回答1:


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

The default scope is singleton

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)

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



来源:https://stackoverflow.com/questions/25583355/spring-service-default-scope

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!