为了账号安全,请及时绑定邮箱和手机立即绑定

java spring4.0如何设置 singleton?

java spring4.0如何设置 singleton?

千巷猫影 2019-01-02 13:01:30
java spring4.0如何设置 singleton? 
查看完整描述

1 回答

?
千万里不及你

TA贡献1784条经验 获得超9个赞

Spring中管理的所有Bean默认都是singleton的
<bean id="command" class="fiona.apple.AsyncCommand" />

如果想将Bean配置成非单例的,可以通过配置scope来说明
<!-- a stateful bean deployed as a prototype (non-singleton) -->
<bean id="command" class="fiona.apple.AsyncCommand" scope="prototype"/>
这样每次获取AsyncCommand对象是都会创建一个新的对象

查看完整回答
反对 回复 2019-01-05
  • 1 回答
  • 0 关注
  • 514 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信