1spring学习笔记(三)回顾
1.1事务管理
基于xml配置
1.配置事务管理器
jdbc:DataSourceTransactionManager
hibernate:HibernateTransactionManager
2.事务通知(详情、属性)
<tx:advice id="" transaction-manager="">
<tx:attributes>
<tx:method name="add*">
<tx:method name="update*">
<tx:method name="delete*">
<tx:method name="find* read-only="true">
- AOP编程,ABCD–> ABC
<aop:config>
<aop:advisor advice-ref="txAdvice" pointcut="execution(* com..*.*(..))">
基于注解
xml 配置
1.事务管理器
2.将配置事务管理器交予spring
<tx:annotation-driven transaction-manager="....">
目标类
@Transactional 类 | 方法
1.2整合Junit
@RunWith(SpringJunit4RnnerClass.class)
@ContextConfiguration(locations="classpath:...xml")
@Autowired 注入
@Test 测试
1.3整合web
web.xml 配置
1.确定xml位置
<context-param>
name:contextConfigLocation
value:classpath:...xml
2.加载x