Spring Service default scope

2019-03-18 03:08发布

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

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)?

1条回答
我命由我不由天
2楼-- · 2019-03-18 03:45

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

查看更多
登录 后发表回答