Spring4 IOC注解开发和xml开发对比
1 创建web项目
2 引入jar包(Spring4的版本需要多引入一个aop的包)
3 编写applicationContext.xml配置文件
注解 ======================
a.引入的是beans的schema
b.只需要配置扫描那些包下的类即可
<context:component-scan base-package="com.spring"></context:component-scan>
xml ======================
a.引入的是beans+context的schema
b.不需要配置任何扫描
4. IOC和DI
注解 =======================
在类中进行配置IOC的DI
xml =======================
在配置文件中配置IOC和DI
5 init-method和destory-method的配置(单例模式且工厂销毁才会执行destory方法)
xml =======================
注解 =======================
6 作用范围的配置
xml =======================
注解 =======================