1. A brief introduction to the Spring bean lifecycle

1. Instantiate

2. Populate

3. Initialize

4. The Destruction of Destruction

 

2. Structure of Spring modules

(1) Core container: including Core, Beans, Context and EL modules.

Core module: Encapsulates the lowest level of framework dependencies, including resource access, type conversion, and some common utility classes. Beans module: Provides the basics of the framework, including reverse control and dependency injection. Bean Factory is the core of container, which is the realization of “Factory design pattern” in essence, and does not need programming to realize “singleton design pattern”, singleton is completely controlled by the container, and advocates interface programming, rather than implementation-oriented programming; All application objects and their relationships are managed by the framework, which really takes you out of the program logic to maintain dependencies between objects, all of which are maintained by the BeanFactory.

Context module: Based on Core and Beans, integrate Beans module functionality and add resource binding, data validation, internationalization, Java EE support, container life cycle, event propagation, etc. The core interface is applicationContext.

The EL module provides powerful expression language support for accessing and modifying attribute values, method calls, accessing and modifying arrays, containers and indexers, naming variables, arithmetic and logical operations, fetching beans from the Spring container, list projection, selection, and general list aggregation.

(2) AOP and Aspects module:

AOP module: The Spring AOP module provides aspect-oriented programming implementation that complies with the AOP Alliance specification, providing common functionality such as logging, permission control, performance statistics, and techniques for separating business logic. And can dynamically add these features to the required code; This specialization reduces the coupling between business logic and common functionality.

The Aspects module: Provides integration with AspectJ, which provides more power than Spring ASP.

Data access/integration module: This module includes JDBC, ORM, OXM, JMS, and transaction management.

Transaction module: This module is used for Spring transaction management, as long as the Spring managed objects can get the benefits of Spring transaction management, no need to conduct transaction control in code, and support programmatic and declarative transaction management.

(3) Data Access related modules

JDBC module: Provides a sample JBDC template that eliminates traditional verbose JDBC coding and the necessary transaction control, and benefits from Spring transaction management.

ORM modules: Provide seamless integration with popular “object-relational” mapping frameworks, including Hibernate, JPA, MyBatis, etc. And you can use Spring transaction management without additional control over transactions.

OXM module: Provides an Object/XML mapping implementation to map Java objects to XML data, or XML data to Java objects. Object/XML mapping implementations include JAXB, Castor, XMLBeans, and XStream.

JMS module: Used for Java Messaging Service (JMS). It provides a set of Message Producer and message consumer templates for easier use of JMS. JMS is used to send messages for asynchronous communication between two applications or in a distributed system.

(4) Web related modules

Web/Remoting module: The Web/Remoting module includes Web, Web-servlet, Web-Struts, and Web-portlet modules.

Web module: Provides basic Web functionality. Examples include multi-file uploads, integrated IoC containers, remote procedure access (RMI, Hessian, Burlap), and Web Service support, and a RestTemplate class to provide easy Restful services access.

Web-servlet module: Provides an implementation of the Spring MVC Web framework. The Spring MVC framework provides annotation-based request resource injection, simpler data binding, data validation, and a very easy-to-use set of JSP tags that work seamlessly with other Spring technologies.

Web-struts module: Provides seamless integration with Struts, supported by both Struts1.x and Struts2.x

(5) Test module: Spring supports Junit and TestNG Test frameworks, and provides some additional spring-based Test functions, such as simulating Http requests when testing Web frameworks.

2. What can Spring do for us?

A. Spring can help us create and assemble dependencies between objects based on configuration files. Spring creates and assembles dependencies between objects based on configuration files. You only need to change the configuration files

B. Spring section-oriented programming can help us achieve uncoupled logging, performance statistics, and security control. Spring faceted programming provides a better way to do this, typically through configuration, and does not require adding any extra code to existing code, which focuses on business logic.

C. Spring can help us manage database transactions very easily. With Spring, we just need to get the connection, execute the SQL, and Spring takes care of everything else.

D. Spring also seamlessly integrates with third-party database access frameworks, such as Hibernate and JPA, and provides its own SET of JDBC access templates to facilitate database access.

E. Spring can seamlessly integrate with third-party Web frameworks (such as Struts and JSF), and it also provides a Spring MVC framework to facilitate Web layer construction.

F. Spring can be easily integrated with Java EE (such as Java Mail, task scheduling) and more technologies (such as caching framework).

More interview questions can pay attention to “demo lock screen interview questions “public account through the mini program or app to learn interview questions