您的位置:首页 > 编程语言 > Java开发

Spring4.0 构造函数配置bean

2016-06-17 17:09 471 查看


Spring IOC   下面代码就是Spring的IOC

ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");



Spring的两种getBean()

HelloWorld helloworld = (HelloWorld) ctx.getBean("helloworld");
HelloWorld helloworld1 =  ctx.getBean(helloworld.getClass());


.class方式只允许[b]applicationContext.xml中存在唯一的id[/b]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  spring