摘要: 1、配置事务: 使用的tx前缀的标签, 导入tx的命名空间 配置事务管理器 , 把事务管理器交给Spring管理: <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager 阅读全文
posted @ 2020-06-13 16:34 64Byte 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 目的: 1) Spring管理SqlSessionFactory 2) Spring管理Mapper代理对象, 在Service层注入Mapper 3) 基于Spring的AOP, 进行事务的控制 1、搭建环境, 导入依赖 spring的jar: spring-context spring-test 阅读全文
posted @ 2020-06-13 16:01 64Byte 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 基于xml 1、环境搭建,添加需要引入的依赖 spring-aop(spring-context, 把aop加载类), spring-aspects <!-- 导入了context,会自动导入先关依赖,包括spring-aop --> <dependency> <groupId>org.spring 阅读全文
posted @ 2020-06-13 14:28 64Byte 阅读(311) 评论(0) 推荐(0) 编辑
摘要: junit之前的写法: //在Before中注入service类 private IUserService userService; @Before public void setUp() throws Exception { //使用xml的方式 ApplicationContext applic 阅读全文
posted @ 2020-06-13 13:46 64Byte 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 基于xml的web开发 目的: Spring容器的创建在Tomcat启动的时候,自动创建, 并且把Spring容器保存到Application域 问题:Servlet对象无法交给Spring管理, Servlet由Tomcat创建管理, Servlet依赖Service层的类, 无法使用Spring 阅读全文
posted @ 2020-06-13 13:25 64Byte 阅读(668) 评论(0) 推荐(0) 编辑