Spring:applicationContext.xml中寫法


<property name="" ref=""></property>
</bean>


<bean id="" lazy-init="" scope="prototype" class="">..
lazy-init="true" 是否延遲對象實例化(默認是同容器一同創建)
scope="prototype" 用來取消容器默認單例模式創建對象
init-method="myinit" 在MyBean類中的myinit方法
destroy-method="destroy" 在MyBean類中的destroy方法


scope屬性的取值 在web(僅限於web項目)環境中,還可以設置所創建的bean對象的生命週期和 request、session
  request 表示bean對象生命週期和request生命週期相同
  session 同session
  global session 相當於application
  single
  prototype
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章