一、注入空值和特殊符号
null值
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104104942919-583619399.png)
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104104949030-199642709.png)
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104104959999-414492132.png)
特殊符号
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104105026284-2003575471.png)
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104105034820-797005738.png)
二、注入外部Bean
1、创建两个类Service类和Dao类
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104105610971-2064402728.png)
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104105617467-681980164.png)
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104105637360-406683401.png)
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104105643725-1230376757.png)
2、在Service调用Dao里面的方法
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104105717321-198633823.png)
3、在Spring配置文件中进行配置
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104105750352-1891148171.png)
三、注入内部Bean和级联赋值
背景
一对多的关系:一个分类下可以拥有很多本书,一本书归属于一个特定的分类下。
创建实体类表示一对多关系
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104105958020-2107267797.png)
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104110008083-1001952609.png)
在Spring配置文件中进行配置【级联赋值写法1】
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104110035181-140052002.png)
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104110048177-11811228.png)
在Spring配置文件中进行配置【级联赋值写法2】
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104110135167-1274666411.png)
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104110148569-1011925093.png)
四、注入集合类型属性
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104110224312-882515291.png)
注入数组类型属性
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104110245667-673489350.png)
注入List类型属性
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104110309747-598113924.png)
注入Map类型属性
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104110335436-868233980.png)
注入Set类型属性
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104110354407-945993077.png)
方法测试
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104110422173-386335246.png)
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104110432134-1748141384.png)
五、注入特殊集合类型属性【对象集合、公共集合提取】
对象集合
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104110707711-773785197.png)
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104110721043-2142167979.png)
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104110739304-2141425312.png)
公共集合提取
1、在Spring配置文件中引入命名空间util
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104110838688-838445528.png)
2、使用util标签完成list集合注入提取
![](https://img2020.cnblogs.com/blog/1743015/202101/1743015-20210104110910205-2017563646.png)