<!-- 配置事务管理器:基于Hibernate--> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <!-- 配置事务管理器:基于JDBC --> <!-- <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> --> <!-- 配置事务策略 --> <tx:advice id="txAdvice" transaction-manager="txManager"> <tx:attributes> <tx:method name="get*" read-only="true" /> <tx:method name="*" rollback-for="Throwable" /> </tx:attributes> </tx:advice> <!-- 用户操作事务配置 --> <aop:config> <aop:pointcut id="userServiceOperation" expression="execution(* com.htdz.eht.service.user.*.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="userServiceOperation" /> </aop:config>