day43-Spring_IOC

0 directory

1.2.3

1. Spring_IOC

1.1  Definition: lightweight framework, the spring of java EE, mainstream framework

1.2 Spring features: IOC control inversion; AOP tangent plane

1.3  Components: Spring’s role in SSM (the glue between SpringMVC and Mybatis framework)

1.4 Spring Concept: The core idea is Bean-oriented (everything is a Bean component)

1.5 Spring advantages: IOC inversion of control (reducing the degree of coupling); AOP aspect-oriented (dedicated people to do specialized tasks); the glue of multiple frameworks (perfectly compatible with SpringMVC and Mybatis)

(1) Low intrusion design

(2) Independent from various application servers

(3) The dependency injection feature makes component relationships transparent and reduces coupling.

(4) Aspect-oriented programming features allow centralized processing of tasks

(5) Good integration with third-party frameworks

1.6  What is IOC

Before spring came out, the control layer used new to call components such as services. After spring came out, we would put these components of service in the spring container for management. This is the first feature of spring, which we call IOC, inversion of control

1.7  Non-IOC

1.8  IOC

(1) Import dependencies:

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-context</artifactId>
  <version>5.2.5.RELEASE</version>
</dependency>

(2) Create in the resources directory and create a Bean object

(3) Test

(4) Test 2

1.9 Spring integrates Mybatis

(1)applicationContext.xml

(2) Entity classes User, UserMapper, UserService

(3) UserviceImpl (annotated @Service identification component (no need to write Bean after global scanning is added to the application, just use annotation directly) and @Autowired injected into UserMapper)

(4)mybatis-config.xml

Guess you like

Origin blog.csdn.net/weixin_63713552/article/details/131924365