spring总结
课程内容.. 1
面向接口编程(面向抽象编程).. 2
什么是IOC(DI),有什么好处.. 2
Spring简介.. 2
Spring IOC配置与应用.. 2
什么是AOP. 4
Spring AOP配置与应用.. 4
Spring整合Hibernate. 7
Struts2.1.6 + Spring2.5.6 + Hibernate3.3.2. 11
课程内容
1. 面向接口(抽象)编程的概念与好处
2. IOC/DI的概念与好处
a) inversion of control
b) dependency injection
3. AOP的概念与好处
4. Spring简介
5. Spring应用IOC/DI(重要)
a) xml
b) annotation
6. Spring应用AOP(重要)
a) xml
b) annotation
7. Struts2.1.6 + Spring2.5.6 + Hibernate3.3.2整合(重要)
a) opensessionInviewfilter(记住,解决什么问题,怎么解决)
8. Spring JDBC
面向接口编程(面向抽象编程)
1. 场景:用户添加
2. Spring_0100_AbstractOrientedProgramming
a) 不是AOP:Aspect Oriented Programming
3. 好处:灵活
什么是IOC(DI),有什么好处
1. 把自己new的东西改为由容器提供
a) 初始化具体值
b) 装配
2. 好处:灵活装配
Spring简介
1. 项目名称:Spring_0200_IOC_Introduction
2. 环境搭建
a) 只用IOC
i. spring.jar , jarkata-commons/commons-loggin.jar
3. IOC容器
a) 实例化具体bean
b) 动态装配
4. AOP支持
a) 安全检查
b) 管理transaction
Spring IOC配置与应用
1. FAQ:不给提示:
a) window – preferences – myeclipse – xml – xml catalog
b) User Specified Entries – add
i. Location: D:\share\0900_Spring\soft\spring-framework-2.5.6\dist\resources\spring-beans-2.5.xsd
ii. URI: file:///D:/share/0900_Spring/soft/spring-framework-2.5.6/dist/resources/spring-beans-2.5.xsd
iii. Key Type: Schema Location
iv. Key: http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
2. 注入类型
a) Spring_0300_IOC_Injection_Type
b) setter(重要)
c) 构造方法(可以忘记)
d) 接口注入(可以忘记)
3. id vs. name
a) Spring_0400_IOC_Id_Name
b) name可以用特殊字符
4. 简单属性的注入
a) Spring_0500_IOC_SimpleProperty
b) <property name=… value=….>
5. <bean 中的scope属性
a) Spring_0600_IOC_Bean_Scope
b) singleton 单例
c) proptotype 每次创建新的对象
6. 集合注入
a) Spring_0700_IOC_Collections
b) 很少用,不重要!参考程序
7. 自动装配
a) Spring_0800_IOC_AutoWire
b) byName
c) byType
d) 如果所有的bean都用同一种,可以使用beans的属性:default-autowire
8. 生命周期
a) Spring_0900_IOC_Life_Cycle
b) lazy-init (不重要)
c) init-method destroy-methd 不要和prototype一起用(了解)
9. Annotation第一步:
a) 修改xml文件,参考文档<context:annotation-config />
10. @Autowired
a) 默认按类型by type
b) 如果想用byName,使用@Qulifier
c) 写在private field(第三种注入形式)(不建议,破坏封装)
d) 如果写在set上,@qualifier需要写在参数上
11. @Resource(重要)
a) 加入:j2ee/common-annotations.jar
b) 默认按名称,名称找不到,按类型
c) 可以指定特定名称
d) 推荐使用
e) 不足:如果没有源码,就无法运用annotation,只能使用xml
12. @Component @Service @Controller @Repository
a) 初始化的名字默认为类名首字母小写
b) 可以指定初始化bean的名字
13. @Scope
14. @PostConstruct = init-method; @PreDestroy = destroy-method;
什么是AOP
1. 面向切面编程Aspect-Oriented-Programming
a) 是对面向对象的思维方式的有力补充
2. Spring_1400_AOP_Introduction
3. 好处:可以动态的添加和删除在切面上的逻辑而不影响原来的执行代码
a) Filter
b) &nbs
补充:软件开发 , Java ,