Spring实例化bean的三种方法
1.用构造器来实例化 [html] view plain copy print ? < bean id= "hello2" class= "com.hsit.hello.impl.ENhello" /> 2.使用静态工厂方法实例化 要写一个bean,bean中定义一个静态方法,生成bean,配置 factory-method 指定 静态方法 ,运行时容器就会自动调用静态方法生成实例 bean [java] view plain copy print ? package com.hsit.hello.impl; import com.hsit.hello.IHello; public class CHhello implements IHello { private String msg; public void sayHello() { System.out.println( "中文" + msg); } public String getMsg() { return msg; } public void setMsg(String msg) { this.msg = msg; } @Override public String toString() { // TODO Auto-generated method stub return "Chinese"; } public