Spring使用xml创建bean对象的方法-创新互联
小编给大家分享一下Spring使用xml创建bean对象的方法,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!
一、导入JAR包
二、配置applicationContext.xml的spring核心配置
三、
public static void main(String[] args) { //1.使用 ApplicationContext 接口,就是在获取 spring 容器 ApplicationContext ac = new ClassPathXmlApplicationContext("bean.xml"); //2.根据 bean 的 id 获取对象 IAccountService aService = (IAccountService) ac.getBean("accountService"); System.out.println(aService); IAccountDao aDao = (IAccountDao) ac.getBean("accountDao"); System.out.println(aDao); }
分享名称:Spring使用xml创建bean对象的方法-创新互联
标题路径:http://azwzsj.com/article/eohid.html