spring事务配置:
- <!-- 事务通知 -->
- <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
- <property name="dataSource" ref="DataSource"></property>
- </bean>
- <!-- 事务控制 -->
- <tx:advice id="txAdvice"
- transaction-manager="transactionManager">
- <tx:attributes>
- <tx:method name="save*" read-only="true" />
- <tx:method name="update*" propagation="REQUIRED"/>
- <tx:method name="del*" propagation="REQUIRED" />
- <tx:method name="get*" propagation="NOT_SUPPORTED" read-only="true" />
- </tx:attributes>
- </tx:advice>
- <aop:config>
- <!-- 管理事务操作 -->
- <aop:pointcut id="servicesPointcut"
- expression="execution(* com.website.model.*.*(..))" />
- <aop:advisor advice-ref="txAdvice"
- pointcut-ref="servicesPointcut" />
- </aop:config>
com.website.model下service类中的方法:
- public int updateTestByid(String mobanname, int id) {
- // TODO Auto-generated method stub
- int isOk = exampleDao.updateMobannameByid("测试1231", 667);
- exampleDao.updateMobannameByid("测试dasd", 1049);
- Integer.parseInt("错误");
- return isOk;
- }