Spring载入配置文件applicationContext.xml的几种方式
来源:互联网 发布:中电科软件与硬件工资 编辑:程序博客网 时间:2024/04/30 15:21
第一种方式:
ClassPathResource cpr = new ClassPathResource("applicationContext.xml");
XmlBeanFactory factory = new XmlBeanFactory(cpr);
Person chinese = (Person) factory.getBean("chinese");//参数为配置文件中的id值
ApplicationContext ac = new ClassPathXmlApplicationContext(new String[]{"applicationContext.xml",
"applicationContext2.xml"});
Person chinese = (Person) ac.getBean("chinese");//参数为配置文件中的id值
System.out.println(chinese.sayGoodBye("张三"));
ClassPathResource cpr = new ClassPathResource("applicationContext.xml");
XmlBeanFactory factory = new XmlBeanFactory(cpr);
Person chinese = (Person) factory.getBean("chinese");//参数为配置文件中的id值
System.out.println(chinese.sayGoodBye("张三"));
ApplicationContext ac = new ClassPathXmlApplicationContext(new String[]{"applicationContext.xml",
"applicationContext2.xml"});
第三种方式:(java的文件系统)
Person chinese = (Person) ac.getBean("chinese");//参数为配置文件中的id值
System.out.println(chinese.sayGoodBye("张三"));
- Spring载入配置文件applicationContext.xml的几种方式
- 读取Spring的配置文件applicationContext.xml几种方法
- Spring 加载xml配置文件的方式 ApplicationContext
- Spring加载配置文件applicationContext.xml的方式
- Spring配置文件applicationContext.xml的两种拆分方式
- Spring配置文件applicationContext.xml的两种拆分方式
- spring ApplicationContext.xml几种加载方式
- Spring加载applicationContext.xml的几种方式
- Spring加载applicationContext.xml的几种方式
- Spring加载applicationContext.xml的几种方式
- Spring获取ApplicationContext方式,和读取配置文件获取bean的几种方式
- 载入Spring配置文件的方式
- Spring的配置文件applicationContext.xml
- Spring的配置文件applicationContext.xml
- 获取spring的ApplicationContext几种方式
- spring 初始化ApplicationContext的几种方式
- 获取spring的ApplicationContext几种方式
- 获取spring的ApplicationContext几种方式
- java 开发规范
- J2EE的十三个规范
- VS2008添加事件的时候,出现“无法执行添加/移除操作,因为代码元素“CXXXDlg”是只读的
- 常用脚本
- [Android Training视频系列]2.2 Pausing and Resuming an Activity
- Spring载入配置文件applicationContext.xml的几种方式
- C#中的事件
- 基于对象的编码加密方法
- android中获取package的versionCode和versionName
- 正则表达式
- 单源最短路径(Dijkstra算法)
- MySQL多IDC部署注意事项
- 简单的贪吃蛇游戏
- TableView代理方法详解(一)