三种思想的提出
BeanFactory流程
例子:
1)maven地址
2)编写接口和接口的实现
3)创建beanFactory工场
在resources创建beans.xml配置文件
在配置文件中创建bean配置
写上唯一id class地址
4)创建测试类测试
默认列表bean工程 创建工程 // XML bean定义读者(reader)
用读者 读取 load负载bean定义 读取配置文件给工厂
用工厂 getbean获取对象测试功能
在一个类中DAO
编写dao接口以及接口的实现同样在bens.xml中配置
例如在UserserviceImpl中注入UserDaoImpl类 在User类中编写SetUserDao函数
在xml中配置子属性 property name写方法名称 首字母小写 ref写要注入哪个个类的xml配置的id
ApplicationContext快速入门
ApplicationContext 接口 创建 ClassPathxmlApplicationContext 实例 (填配置文件名称)直接获得配置文件中对象
ApplicationContext更为的先进包含BeanFactory的内容一般都使用ApplicationContext
两者的关系: