当前位置: 移动技术网 > IT编程>开发语言>Java > Spring如何使用xml创建bean对象

Spring如何使用xml创建bean对象

2020年08月08日  | 移动技术网IT编程  | 我要评论

一、导入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); 
 }

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网