Spring's three core components and their main division of labor

In Spring, I personally think that the three core components are: beans, context, and core.

1. beans: beans are the most important one in the core, because the other two are around it. We all know that the IOC (inversion of control) in Spring is to reverse the object (bean) that was originally controlled by the programmer and hand it over to Spring to manage it for us. Naturally, the beans here are a collection of objects that we need to use in our Java applications. All I say is the core of this core, because you don't have beans, Spring doesn't need to exist.

2. context: Literal understanding is the meaning of context, as if it is the term we use in the article, but why did the name of Spring (that is, the inventor of Spring) use this name? In my opinion, the text in the term "context" here is actually a Spring-managed bean. We regard the Spring container as an article, and the bean is each paragraph or each sentence, and "up and down" can be understood as the dependency (reference) between beans in Java. We all know that the paragraphs of the document are related to each other (what is the connection between the previous and the next, etc.). Of course, there will also be mutual references and other relationships between our beans in Java. With the previous understanding, we actually probably know the role of context. The role is to manage the relationship between beans and beans in Spring.

3, core: This translation is the meaning of the core. But in fact, its role is mainly to serve the context when it manages the relationship between beans and beans in Spring. In fact, it is a tool class that submits tools for Spring management beans. The classes here are classes in our lives, not classes in the Java world! In Java it might be an interface.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326506116&siteId=291194637