摘要: @Autowired和@Resource等注解是将Spring容器中的bean注入到属性,而@Component等注解是将bean放入Spring容器中管理。 @Autowired spring2.1中允许用户通过@Autowired注解对Bean的属性变量.属性Setter方法以及构造函数进行标注 阅读全文
posted @ 2016-12-28 15:13 旧爱久居于心 阅读(12180) 评论(0) 推荐(0) 编辑
摘要: 1.用构造器来实例化 <bean id="hello2" class="com.hsit.hello.impl.ENhello" /> 2.使用静态工厂方法实例化 要写一个bean,bean中定义一个静态方法,生成bean,配置factory-method指定静态方法,运行时容器就会自动调用静态方法 阅读全文
posted @ 2016-12-28 08:41 旧爱久居于心 阅读(304) 评论(0) 推荐(0) 编辑