1. 程式人生 > >spring手動初始化bean

spring手動初始化bean

如果檔案在classpath下:

ApplicationContext ctx= new ClassPathXmlApplicationContext(new String[]{“beans.xml”,”application.xml”});  

BeanFactory  factory =ctx;  

如果檔案不在classpath下:

ApplicationContext ctx = new FileSystemXmlApplicationContext(new String[]{"file:D:/workspace_dna2/GdnaDataWebService/src/main/webapp/WEB-NF/applicationContext.xml", "file:D:/workspace_dna2/GdnaDataWebService/src/main/webapp/WEB-INF/xfire-servlet.xml"});