Spring Service default scope

后端 未结 1 1177
刺人心
刺人心 2021-02-06 23:47

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

Does it make sense designing a Service implementation to store info about the c

相关标签:
1条回答
  • 2021-02-07 00:24

    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

    0 讨论(0)
提交回复
热议问题