Table of contents
Although springboot is more commonly used now, only by fully mastering spring can you use springboot handy, so spring again from beginning to end.
1. Framework overview:
1.srping is a lightweight open source JAVAEE framework
2.Sping can solve the complexity of enterprise application development
3.Two cores of Spring: IOC and AOP
1) IOC inversion of control, which means handing over the object creation process to Spring management
2) AOP is aspect-oriented and enhances functions without modifying the source code
4. Spring features:
1) Convenient decoupling, simplified development
2) Aop programming
3) Convenient testing
4) Convenient integration of other frameworks
5) Convenient transaction operations
6) Reduce API development difficulty
Let's demonstrate with Spring5
2. Introductory case:
<!--测试相关-->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.7.1</version>
<scope>test</scope>
</dependency>
<!--Spring核心基础依赖-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.3.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.3.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.3.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>5.3.6</version>
</dependency>
<!--日志相关-->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
3. IOC introduction
3. DI injection
1. set injection
2. Parameter injection
3. P namespace injection
4. Inject other types
1. Literal volume
①, set a null value
②, special symbol injection
2, external BEAN
3. Cascade assignment
4. Inject collection
5、FactoryBean
6. The scope of the bean
、
7. Bean life cycle
The life cycle of the bean is as follows: Execution of construction parameters —> setting properties —> initialization —> obtaining instances —> destroying instances.
8. Automatic assembly
9. External properties file
Take the database configuration file as an example: