Spring

一:Spring核心

Spring实现简化开发的四项策略:

1、基于POJO的轻量级和最小侵入式编程;

2、通过依赖注入和面向接口编程实现松耦合;

3、基于切面和惯例进行声明式编程;

4、通过切面和模板减少样板式代码。


beanFactory 与factoryBean

beanFactory:基础核心接口,通过反射机制获取bean。

factoryBean:

If you have complex initialization code that is better expressed in Java as opposed to a (potentially) verbose amount of XML, you can create your own FactoryBean, write the complex initialization inside that class, and then plug your custom FactoryBean into the container.

当xml配置pojo比较复杂时,以java中类的定义方法来定义bean对象,最后只需在xml中注册即可。通过该方法获取的bean实际上是该bean的getObject()方法获取的对自身引用。

posted @ 2019-10-31 21:48  wanghuanyeah  阅读(125)  评论(0)    收藏  举报