`
lfwer
  • 浏览: 84251 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

spring中调用bean

 
阅读更多

1、使用BeanWrapper
HelloWorld hw=new HelloWorld();
BeanWrapper bw=new BeanWrapperImpl(hw);
bw.setPropertyvalue(msg,HelloWorld);
system.out.println(bw.getPropertyCalue(msg));
2、使用BeanFactory
InputStream is=new FileInputStream(config.xml);
XmlBeanFactory factory=new XmlBeanFactory(is);
HelloWorld hw=(HelloWorld) factory.getBean(HelloWorld);
system.out.println(hw.getMsg());
3、使用ApplicationConttext
ApplicationContext actx=new FleSystemXmlApplicationContext(config.xml);
HelloWorld hw=(HelloWorld) actx.getBean(HelloWorld);
System.out.println(hw.getMsg());

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics