目录
实验任务5:创建UserService业务逻辑实现添加数据操作
实验目的:
熟悉Spring事务管理的3个核心接口
了解Spring事务管理的两种方式
掌握基于xml和Annotation的声明方式事务的使用
实验内容:
实验任务1:创建项目,引入架包
实验任务2:创建一个数据库spring04并创建一个数据表
实验任务3:配置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: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.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<!--开启注解-->
<context:component-scan base-package="dao,service"></context:component-scan>
<!-- 1. 数据源对象: C3P0连接池 -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.cj.jdbc.Dri