Spring中操作applicationContext.xml
2010-08-05 15:48
429 查看
ApplicationContext ac = null;
方法1. 在classpath根路径查找
ac = new ClassPathXmlApplicationContext("your.xml");
方法2. 在classpath下的test文件夹下查找
ac = new ClassPathXmlApplicationContext("classpath:test/your.xml");
方法3. 在某个类所在的路径中查找
ac = new ClassPathXmlApplicationContext("your.xml",HelloWorld.class);
方法4. 通过URL定位查找
ac = new ClassPathXmlApplicationContext("file:D:/aaa/bbb/your.xml");
方法5. 直接传入路径:
ac = new FileSystemXmlApplicationContext("D:/aaa/bbb/your.xml");
方法6. 指定多个配置文件
ac = new ClassPathXmlApplicationContext(
new String[]{"test1.xml","aaa/test2.xml"}
);
============
classpath*:
查找所有路径下的test.xml
ac = new ClassPathXmlApplicationContext("classpath*:*/test.xml");
方法1. 在classpath根路径查找
ac = new ClassPathXmlApplicationContext("your.xml");
方法2. 在classpath下的test文件夹下查找
ac = new ClassPathXmlApplicationContext("classpath:test/your.xml");
方法3. 在某个类所在的路径中查找
ac = new ClassPathXmlApplicationContext("your.xml",HelloWorld.class);
方法4. 通过URL定位查找
ac = new ClassPathXmlApplicationContext("file:D:/aaa/bbb/your.xml");
方法5. 直接传入路径:
ac = new FileSystemXmlApplicationContext("D:/aaa/bbb/your.xml");
方法6. 指定多个配置文件
ac = new ClassPathXmlApplicationContext(
new String[]{"test1.xml","aaa/test2.xml"}
);
============
classpath*:
查找所有路径下的test.xml
ac = new ClassPathXmlApplicationContext("classpath*:*/test.xml");
相关文章推荐
- spring中ClassPathXmlApplicationContext和FileSystemXmlApplicationContext的路径问题
- 【Spring整合Struts2】Could not open ServletContext resource [/WEB-INF/application.xml]错误解决
- JPA+Spring下,applicationContext.xml中的entityManagerFactory中的class设置问题
- spring配置文件 applicationContext.xml
- spring ApplicationContext.xml几种加载方式
- Spring加载applicationContext.xml的几种方式
- springmvc.xml和applicationContext.xml配置的特点
- spring配置文件详解(applicationContext.xml详解)
- java.io.FileNotFoundException: D:\Workspaces\MyEclipse 8.5\spring\applicationContext.xml (系统找不到指定的文
- java.lang.NoSuchMethodError: org.springframework.web.context.support.XmlWebApplication的错误
- Spring Data JPA applicationContext.xml 配置文件报错的解决办法
- Spring启动<三>——XmlWebApplicationContext
- Spring IOC 源码-ClassPathXmlApplicationContext-bean解析
- spring+hibernate:在applicationCOntext.XML中配置C3P0参数说明
- springMVC之web.xml,spring-mvc.xml与applicationContext.xml
- spring+hibernate之applicationContext.xml配置
- Spring 配置文件applicationContext.xml
- 详解Spring的applicationContext.xml文件代码
- 先码后看 Spring中ClassPathXmlApplicationContext与FileSystemXmlApplicationContext 侵立删
- hibernate3使用注解,spring配置文件applicationContext.xml的配置