spring 中加載xml配置文件的方式
XmlBeanFactory
ClassPathXmlApplicationContext
FileSystemXmlApplicationContext
XmlWebApplicationContext
一:XmlBeanFactory 引用資源
Resource resource = new ClassPathResource(
BeanFactory factory = new XmlBeanFactory(resource);
二:ClassPathXmlApplicationContext 編譯路徑
ApplicationContext factory=new ClassPathXmlApplicationContext(
ApplicationContext factory=new ClassPathXmlApplicationContext(
ApplicationContext factory=new ClassPathXmlApplicationContext(
ApplicationContext factory=new ClassPathXmlApplicationContext(
三 : 用文件系統的路徑
ApplicationContext factory=new FileSystemXmlApplicationContext(
//使用了 classpath: 前綴
ApplicationContext factory=new FileSystemXmlApplicationContext(
ApplicationContext factory=new FileSystemXmlApplicationContext(
ApplicationContext factory=new FileSystemXmlApplicationContext(
四: XmlWebApplicationContext 是專為Web工程定制的
ServletContext servletContext = request
ApplicationContext ctx = WebApplicationContextUtils
From:http://tw.wingwit.com/Article/program/Java/ky/201311/29126.html