java spring4.0如何設置 singleton?
1 回答

胡說叔叔
TA貢獻1804條經驗 獲得超8個贊
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對象是都會創建一個新的對象
- 1 回答
- 0 關注
- 1434 瀏覽
添加回答
舉報
0/150
提交
取消