Spring框架中使用到了大量的設計模式,下面列舉了比較有代表性的:
- 代理模式—在AOP和remoting中被用的比較多。
- 單例模式—在spring配置文件中定義的bean默認為單例模式。
- 模板方法—用來解決代碼重復的問題。比如. RestTemplate,
JmsTemplate
,JpaTemplate。
- 工廠模式—BeanFactory用來創建對象的實例。
- 適配器--spring aop
- 裝飾器--spring data hashmapper
- 觀察者-- spring 時間驅動模型
- 回調--Spring ResourceLoaderAware回調接口