Spring Framework - MacKittipat/note-developer GitHub Wiki
Spring Framework
-
Front Controller
- DispatcherServlet servlet is the front controller in Spring MVC that intercepts every request and then dispatches requests to an appropriate controller
-
Inversion of Control (IoC) principle
- When using this principle, instead of allowing the app to control the execution, we give control to some other piece of software—in our case, the Spring framework
- The app execution is controlled by the dependency. The Spring framework controls an app during its execution.
-
Dependency Injection
- One class can use an instance of another class without knowing any details about how that object was constructed or its exact implementation class
- If we have a UserController that needs to retrieve data from a database using a UserRepository, rather than directly creating a UserRepository class within the UserController, which would tightly couple both classes, we aim to decouple them by creating the UserRepository separately from the UserController. Subsequently, we inject the UserRepository into the UserController either through a setter or constructor method.