使用@Transactional进行声明式事务管理的完整配置代码示例
1 <tx:annotation-driven transaction-manager="transactionManager" /> 2 3 <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> 4 <property name="dataSource" ref="dataSource"/> 5 </bean> 6 7 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destory-method="close"> 8 <property name="url" value="jdbc:mysql://localhost/dbName"/> 9 <property name="driverClassName" value="com.mysql.jdbc.Driver"/> 10 <property name="username" value=""/> 11 <property name="password" value=""/> 12 </bean> 13 14 <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> 15 <property name="dataSource" ref="dataSource"/> 16 </bean>