(1) Spring basics|What is Spring|Spring related concepts|Why Spring is a lightweight container

table of Contents

Preface

1. What is a lightweight container

2. Why use Spring

Three, interview answer


 

Preface

I want to write about spring and springmvc series. After all, this kind of framework is based on the framework. In the early years, I used SSM or SSH architecture. They are very popular, including the one I just graduated. I used spring or The springmvc series of projects, so some early projects, when springBoot and microservices have not yet started to become popular, there is a springMVC architecture project that is actually relatively cutting-edge. Many banking systems may still use the springMVC series of projects.

So next I will share some spring and springmvc series of blog posts. I hope everyone can advise and learn from each other. Please point out the incorrect and inappropriate points.

When you go to the interview, when you introduce the project, when you introduce the project using spring or springMVC or springBoot, the interviewer will ask you a question: Do you know the difference and connection between spring, springMVC, and springBoot? ?

This is basically a compulsory test. You can pay attention to it. At this time, you say that a large series of 800-word essays are actually useless. The interviewer may not listen to them all. You only need to grasp a few points. In the following blog update series, I will also teach you how to answer the interviewer's question.

 

1. What is a lightweight container

Container: The spring container helps us manage the business logic layer. There are many business logic objects in it. When there are objects, there are life cycle management (creation and destruction) of the objects.


Lightweight: The services that spring provides to users are entirely up to the users to decide, and which services spring wants to use to start and use. But the heavyweights give you all the services as long as you use them, and you can't customize them yourself.

The spring container can never run independently, it must be started by other containers, or started by the web container, or started by the ejb container.

 

2. Why use Spring

1. Dynamic decoupling, convenient development, and interface-oriented design
Through the IoC container provided by Spring, we can hand over the dependencies between objects to Spring to control, avoiding excessive program coupling caused by hard coding. With Spring, users no longer need to write code for low-level requirements such as single-instance mode classes and property file analysis, and can focus more on upper-level applications

2. Convenient program testing TDD (Test-Driven Development)
can use non-container-dependent programming for almost all testing work. In Spring, testing is no longer an expensive operation, but something that can be done at hand.

3. Reducing the difficulty of using Java EE API
Spring provides a simple encapsulation layer for many difficult-to-use Java EE APIs (such as JDBC, JavaMail, remote calls, etc.). Through Spring's simple encapsulation, these Java EE APIs are difficult to use To reduce.

4. Convenient integration of various excellent frameworks
Spring does not exclude various excellent open source frameworks. On the contrary, Spring can reduce the difficulty of using various frameworks. Spring provides various excellent frameworks (such as Struts, Hibernate, Hessian, Quartz), etc. Direct support.

5. AOP programming support
Through the AOP function provided by Spring, it is convenient for aspect-oriented programming. Many functions that are not easy to implement with traditional OOP can be easily handled by AOP.

6. Support for declarative transactions
In Spring, we can free ourselves from the monotonous and boring transaction management code, and flexibly manage transactions in a declarative manner to improve development efficiency and quality.

7. All exception handling methods are converted to Unchecked.

8. Good design, easy to extend, many reusable components

 

Three, interview answer

When you answer Spring, you just need to mention the above two points, but there may be more content and it is impossible to remember. You can simply answer as follows, or you can, after all, it is an interview. Answer More answers and less will not be too different, just the same meaning

What is Spring? The core function of Spring is a lightweight container, which helps us manage business objects, the life cycle of objects, and the relationship between objects and objects, and the lightweight thing is that the services provided allow customization Yes; he has two core components, IOC (Inversion of Control) and AOP (Aspect Oriented Programming)

 

Guess you like

Origin blog.csdn.net/qq_27471405/article/details/109032451