spring question and answer

1. What is the Spring framework? What are the main modules of the Spring framework?
The Spring framework is a Java platform that provides comprehensive and extensive basic support for the development of Java applications.

Spring helps developers solve basic problems in development, allowing developers to focus on application development.
The Spring framework itself is also carefully built in accordance with the design pattern, which allows us to integrate the Spring framework in a development environment without worrying about how Spring works in the background.
The Spring framework has integrated more than 20 modules so far. These modules are mainly divided into the core container, data access/integration, Web, AOP (Aspect Oriented Programming), tools, message and test modules as shown in the figure below.

2. What are the benefits of using the Spring framework?

Here are some of the main benefits of using the Spring framework:
Dependency Injection (DI) method makes the dependencies between the constructor and the JavaBean properties file clear.
 Compared with EJB containers, IoC containers tend to be more lightweight. In this way, it becomes very advantageous for the IoC container to develop and publish applications with limited memory and CPU resources.

Spring does not work behind closed doors. Spring utilizes existing technologies such as ORM framework, logging framework, J2EE, Quartz and JDK Timer, and other view technologies.

 The Spring framework is organized in the form of modules. The module to which it belongs can be seen by the number of the package and class, and developers only need to select the module they need.

 It is very simple to test an application developed with Spring, because the environment code related to the test is already included in the framework. Even simpler is that by using POJO classes in the form of JavaBeans, you can easily use dependency injection to write test data.
Spring's web framework is also a well-designed Web MVC framework, which provides developers with a powerful option in addition to mainstream frameworks such as Struts, over-designed, and unpopular web frameworks.

Spring provides a convenient transaction management interface, suitable for small local transaction processing (such as in a single DB environment) and complex common transaction processing (such as the use of JTA complex DB environment).
3. What is Inversion of Control (IOC)? What is dependency injection?
Inversion of control is used in the field of software engineering. It is a programming technique in which coupled objects are bound by assembler objects at runtime. The coupling relationship between objects is usually unknown at compile time. In the traditional programming method, the flow of business logic is determined by the objects in the application that have already been set up. In the case of using inversion of control, the flow of business logic is determined by the object relationship

Determined by the diagram, the object relationship diagram is instantiated by the assembler. This implementation can also abstract the definition of the association relationship between objects. The binding process is achieved through "dependency injection".
Inversion of control is a design paradigm for the purpose of giving more control to the target components in the application, and it has played an effective role in our actual work.
Dependency injection is a mode of instantiating functional objects that other objects depend on when the required function is not known from which class at the compilation stage. This requires a mechanism to activate the corresponding components to provide specific functions, so dependency injection is the basis of inversion of control. Otherwise, if the component is not controlled by the framework, how does the framework know which component to create?
There are still three implementations of injection in Java:
1. Constructor injection

2.Setter method injection

3. Interface injection

Guess you like

Origin blog.csdn.net/qq_42918433/article/details/113783859