Spring Framework encourages the use of a number of design patterns by default. A few examples are as follows:
- Dependency Injection or Inversion of Controller: This is the fundamental design pattern Spring Framework is built to enable. It enables loose coupling and testability.
- Singleton: All Spring beans are singletons by default.
- Factory Pattern: Using the bean factory to instantiate beans is a good example of the factory pattern.
- Front Controller: Spring MVC uses DispatcherServlet as the Front Controller. So we use the Front Controller pattern when we develop applications with Spring MVC.
- Template Method: Helps us avoid boilerplate code. Many Spring-based classes--JdbcTemplate and JmsTemplate--are implementations of this pattern.