基于注解的事务控制配置
-
配置事务管理器
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver">property> <property name="url" value="jdbc:mysql://localhost:3306/myword">property> <property name="username" value="root">property> <property name="password" value="123456">property> bean> ? <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="datasource" ref="datasource">property> bean>
-
开启Spring对注解事务的支持
<tx:annotation-driven transaction-manager="transactionManager">tx:annotation-driven>
-