首先的在最上面加上aop和tx 命名空间
<!-- 配置hibernate事务管理器 -->
<bean id="TransManger" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<!-- 配置事务特性 -->
<tx:advice id="Transtx" transaction-manager="TransManger">
<tx:attributes>
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="find*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- 使用aop 注入 -->
<aop:config>
<aop:pointcut id="pService" expression="execution(* com.qdc.service.*.*.*(..))"/>
<aop:advisor advice-ref="Transtx" pointcut-ref="pService"/>
</aop:config>
转载于:https://www.cnblogs.com/mxy-/p/5102856.html