本文共 853 字,大约阅读时间需要 2 分钟。
对象由谁创建?
对象属性如何设置? 控制? 反转? 优点?Hello.java
public class Hello { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } public void show() { // TODO Auto-generated method stub System.out.println("Hello:"+name); }}
bean.xml
Test.java
public class Test { public static void main(String[] args) { //解析bean.xml文件,生成管理相应的bean对象 ApplicationContext ctx=new ClassPathXmlApplicationContext("bean.xml"); Hello h=(Hello) ctx.getBean("hello"); h.show(); }}
转载地址:http://yutwz.baihongyu.com/