Resource res = new ClassPathResource("applicationContext.xml");
BeanFactory factory = new XmlBeanFactory(res);
/*不在applicationContext.xml配置PropertyPlaceholderConfigurer
* Properties props = new Properties();
*
* props.load(new FileInputStream("init.properties"));
* PropertyPlaceholderConfigurer cfg = new
* PropertyPlaceholderConfigurer(); cfg.setProperties(props);
*/
//配置PropertyPlaceholderConfigurer
PropertyPlaceholderConfigurer cfg = (PropertyPlaceholderConfigurer) factory
.getBean("placeholderConfig");
cfg.postProcessBeanFactory((XmlBeanFactory) factory);
IfCaculate caculateService = (IfCaculate) factory
.getBean("caculateService");
caculateService.doPlus(123, 321);
caculateService.doMultiply(123, 321);
IfListAll listAll = (IfListAll) factory.getBean("listService");
List all = listAll.listAll();
for (Iterator iter = all.iterator(); iter.hasNext();) {
TestBean tb = (TestBean) iter.next();
System.out.println(tb.getId() + "," + tb.getParam1() + ","
+ tb.getParam2() + "," + tb.getValue());