开发步骤

- 导入 Spring 坐标
- 创建 Bean 即 dao 层的 lmpl 实现类
- 创建 applicationContext.xml 配置文件,在文件中配置 Bean
- 创建 ApplicationContext 对象 getBean( Bean 的 id 标识)
- 注意:这样子是实现解耦的,Spring 客户端.getBean(id 标识) 中的 id 标识可以是不变的,我们只需在 xml 配置文件中修改 Bean 的全包名即可!
代码实现
1. 导入 Spring 坐标
2. 创建 Bean
3. 创建配置文件applicationContext.xml
将 UserDaoImpl 配到配置文件当中
配置文件叫啥都行,但是开发当中习惯将其叫为 applicationContext
4. 创建 ApplicationContext 对象 getBean
下面的 app 就是 Spring 的客户端代码

解析:// 加载配置文件,创建 Spring 容器ApplicationContext app = new ClassPathXmlApplicationContext("applicationContext.xml");
