spring bean實現init/destory生命週期方法的三種方式

  • 實現InitializingBean和DisposableBean接口,實現afterPropertiesSet()和destroy()方法
  • 使用@PostConstruct和@PreDestroy進行方法註解
  • 在xml中用init-method和destroy-method指定init方法和destroy方法。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章