Spring is an open source framework created to address the complexity of enterprise application development. One of the main advantages of a framework is its hierarchical architecture, which allows you to choose which component to use while providing an integrated framework for J2EE application development.
7 modules of Spring framework
Each module (or component) that makes up the Spring framework can exist alone or be implemented in conjunction with one or more other modules. The functions of each module are as follows:
1 Core module
The SpringCore module is the core container of Spring. It implements the IOC mode and provides the basic functions of the Spring framework. The BeanFactory class contained in this module is the core class of Spring, responsible for the configuration and management of JavaBeans. It uses Factory mode to implement IOC, i.e. dependency injection. Speaking of JavaBean, it is a Java class that follows certain design patterns to make them easy to use with other development tools and components. Definition JavaBean is a reusable component written in the JAVA language. To write a JavaBean, the class must be a concrete class and a public class, and has a constructor without parameters.
2Context module
The SpringContext module inherits the BeanFactory (or Spring core) class and adds functions such as event processing, internationalization, resource loading, transparent loading, and data verification. It also provides access methods for framework-based beans and many enterprise-level functions, such as JNDI access, support for EJB, remote calls, integrated template framework, Email and timed task scheduling, etc.
3AOP module
Spring integrates all AOP features. Transaction management can make any Spring managed objects AOP. Spring provides an AOP framework written in standard Java language, and most of its content is developed based on the API of the AOP Alliance. It makes applications leave EJB complexity aside, but has the key features of traditional EJB.
4DAO module
DAO is the abbreviation of DataAccessObject. The DAO model idea is to separate business logic code from database interaction code to reduce the coupling between the two. The DAO mode can make the structure clearer and the code simpler. The DAO module provides the abstraction layer of JDBC, simplifies exception errors for database vendors (no longer inheriting large batches of code from SQLException), greatly reduces the writing of code, and provides support for declarative and programmatic transactions.
5ORM mapping module
SpringORM modules provide support for existing ORM frameworks. Various popular ORM frameworks are already very mature and have a large-scale market. Spring does not need to develop new ORM tools. It provides perfect integration capabilities for Hibernate, and also supports other ORM tools. Note that Spring provides various interfaces (supports), and currently popular closed mapping frameworks for lower-level databases, such as ibatis, Hibernate, etc.
6Web modules
This module is built on the SpringContext, which provides the context of the Context of the Servlet listener and the web application. Integration is provided for existing web frameworks such as JSF, Tapestry, Structs, etc. Structs is based on a recognized good model of MVC. Struts is involved in M, V and C, but it mainly provides a good controller and a customized label library, which means that its focus is on C and V. Therefore, it is born with a series of advantages brought by MVC, such as: clear structural hierarchy, high reusability, increasing the robustness and scalability of the program, facilitating the division of labor between development and design, and providing centralized and unified authority control, verification, internationalization, logging, etc.
7MVC module
The pringWebMVC module is built on the core functions of Spring, which allows it to have all the features of the Spring framework, adapt to a variety of multi-view, template technologies, internationalization and verification services, and achieve a clear separation of control logic and business logic. Let’s talk about the role of MVC in JSP. The concept of “controller” is introduced here. The controller is generally served by Servlets. The client’s request is no longer directly sent to a JSP page that processes business logic, but to this controller. The controller then calls different transaction logic according to the specific request and returns the processing result to the appropriate page. Therefore, this Servlet controller provides an application with a hub for front-back-end processing. On the one hand, it provides a suitable entry point for the verification, identity authentication, logging and realizing international programming of input data; on the other hand, it also provides the possibility of stripping business logic from JSP files. After the business logic is separated from the JSP page, the JSP file becomes something that simply completes the display task, which is often called View. The independent transaction logic becomes what people often call Model, and the controller Control itself constitutes the MVC model. Practice has proved that the MVC model provides great convenience for the development and maintenance of large-scale programs.
Summarize
The above is all the brief introduction of the seven major modules of Spring framework in this article, I hope it will be helpful to everyone. Interested friends can continue to refer to this site:
Simple exploration of the working principle of Spring
Spring framework web project practical code sharing
Understand dependency injection and control inversion in Spring
If there are any shortcomings, please leave a message to point it out. Thank you friends for your support for this site!