读取Spring配置文件ApplicationContext.xml的5种方法
来源:互联网 发布:淘宝低价风险交易 编辑:程序博客网 时间:2024/06/11 21:08
1.利用ClassPathXmlApplicationContext,这种方式配置文件应该放在类包同路径下
Java代码:
ApplicationContext ct=new ClassPathXmlApplicationContext("applicationContext01.xml");ct.getBean("");
2.利用FileSystemXmlApplicationContext,这种方法可以将配置文件放在工程的直接目录下
Java代码:
ApplicationContext ct=new FileSystemXmlApplicationContext("applicationContext01.xml");ct.getBean("");
3.显式给出配置文件的绝对路径,我们假定配置文件位于工程主目录中的conf文件夹中
Java代码:
String path=System.getProperty("user.dir");ApplicationContext ct=new FileSystemXmlApplicationContext(path+"//conf//applicationContext01.xml");ct.getBean("");
4.利用FileSystemResource,可以将配置文件放在工程直接目录下
Java代码:
Resource rs=new FileSystemResource("applicationContext01.xml");BeanFactory ct=new XmlBeanFactory(rs);ct.getBean("");
5.显式给出配置文件的绝对路径,我们假定配置文件位于工程主目录中的conf文件夹中
Java代码:
String path=System.getProperty("user.dir");Resource rs=new FileSystemResource(path+"//conf//applicationContext01.xml");BeanFactory ct=new XmlBeanFactory(rs);ct.getBean("");
阅读全文
0 0
- 读取Spring的配置文件applicationContext.xml的5种方法
- 读取Spring的配置文件applicationContext.xml的5种方法
- 读取Spring配置文件ApplicationContext.xml的5种方法
- 读取Spring的配置文件applicationContext.xml几种方法
- applicationContext.xml配置文件的读取
- 模拟spring的注入和读取配置文件(ApplicationContext.xml)
- 模拟spring的注入和读取配置文件(ApplicationContext.xml)
- 读取applicationContext.xml(spring配置文件)文件
- Spring的配置文件applicationContext.xml
- Spring的配置文件applicationContext.xml
- spring的配置文件applicationContext.xml配置文件详解
- 读取配置applicationContext.xml 的5种方法
- spring读取applicationContext.xml获得BeanFactory的方法
- Spring的applicationContext.xml--spring 配置文件详解
- spring配置文件applicationContext.xml
- spring配置文件 applicationContext.xml
- Spring配置文件-applicationContext.xml
- Spring配置文件applicationContext.xml的两种拆分方式
- python实现不使用额外空间去除重复元素
- 计算二进制中含有1的个数
- bzoj
- 2017-8-5
- bzoj 4326 && Noip2015提高组运输计划
- 读取Spring配置文件ApplicationContext.xml的5种方法
- spring多环境变量配置 @profile
- Leap Motion
- 怎样选择适合的数据中心架构
- java基础知识汇总
- 研究表明DCIM可通过自动化节省成本
- Java 工程师成神之路
- java 做题小细节
- Difference Between HTM and HTML