package com.example;
import com.example.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* Hello world!
*
*/
public class App {
public static void main(String[] args) {
//使用Spring框架提供的接口获取IoC容器
//将配置文件作为参数传递进去以获取参数中的上下文对象
ApplicationContext ctx = new ClassPathXmlApplicationContext("springconfig.xml");
//使用接口中的方法获取bean,将bean的id传递进去
//获取到的bean是个对象,Object类型的,需要转换成BookDao类型的
UserService userService = (UserService) ctx.getBean("userService");
userService.save();
}
}
期末向Spring IoC源代码
需积分: 0 155 浏览量
2023-12-11
15:23:03
上传
评论
收藏 9KB ZIP 举报
![avatar](https://profile-avatar.csdnimg.cn/ac2cbd0cdde541c59795c122c2d3960a_weixin_62880070.jpg!1)
咏婵
- 粉丝: 71
- 资源: 4
最新资源
- sqlitestudio-2.1.5
- xss 平台 源码资源打包
- The LCD1602 monitor + 3-Port USB 2.0 Hub cape for Loongson 2K100
- Performe data analysis, data visualization with Python and any B
- Getting familiar with Big data concept using Python library: PyS
- 475371489537032016335_从物质实体到关系实在_罗嘉昌中国社会科学出版社.djvu
- SheetBuddy is a Python library for performing exploratory data a
- blumind 3.2 (轻量的思维导图软件)
- 全国大学生建模大赛经典题目解析与相关知识点总结.docx
- 基于STM32的病室监护系统单片机代码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)