Spring概念

1.spring是一个开源的轻量级框架


2.spring的核心主要有两部分:

  2.1 aop :面向切面编程,扩展功能不是修改源代码实现

  2.2 ioc :控制反转

Spring概念

  Spring概念

3.spring是一站式框架

Spring概念Spring概念


4.spring版本

struts2

hibernate5.x

spring4.x


Spring的ioc操作

Spring概念


IOC底层原理

1. ioc底层原理使用的技术

  (1)xml配置文件

  (2)dom4j解析xml

  (3)工厂设计模式

  (4)反射


2. 画图分析ioc实现原理


Spring概念


入门案例

。。。


Bean标签常用属性

(1)id:起的名称,id属性值名称任意命名

id属性值不能包含特殊符号

根据id值得到配置对象

(2)class:

(3)name:

(4)scope:


属性注入

1.创建对象的时候,向类里面的属性设置值

2.属性注入值的方式介绍(三种)

2.1 使用set方法注入

2.2 使用有参数的构造方法注入

2.3 使用接口注入

Spring概念


3 在spring框架里面,仅支持前两种方式

2.1 使用set方法注入

2.2 使用有参数的构造方法注入

使用有参数的构造方法注入

第一步,PropertyDemo1.java类

Spring概念


第二步:

Spring概念


第三步:测试

Spring概念


使用set方法注入(这是重点)


1.第一步:建Book.java类

Spring概念


2.第二步:

Spring概念


3.第三步:

Spring概念