spring手动初始化bean

来源:互联网 发布:淘宝黑搜二维码卡首页 编辑:程序博客网 时间:2024/05/06 19:43

如果文件在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"});

0 0