使用Spring的好处:
1.降低组件之间耦合度,实现软件各层之间的解耦
2.使用容器的各种服务,如 事务处理,消息服务
3.实现单例模式(单例singleton 非单例 scope="prototype")
4.提供AOP技术,实现权限拦击,运行期控制
5.提供辅助类,加快开发进度 JdbcTemplate,HibernateTemplate
6.支持主流应用框架提供集成支持,便于应用开发
懒加载:lazy-init="true" 当spring容器初始化的时候不实例bean,只有在第一次获取(getbean)的时候才初始化
初始化方法 init-method="initmethod"
销毁方法 destroy-method="destorymethod"
Spring使用到的jar包:
dist\spring.jar
lib\jakarta-commons\commons-logging.jar
Aop编程需要的:
lib\aspectj\aspectjweaver.jar aspectjrt.jar
libt\cglib\cglib-nodep.jar
注解需要的:
lib\j2ee\common-annotations.jar
Spring的配置文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
</beans>