<!-- 配置sessionFactory --> <bean id="sessionFacory" class="org.springframework.orm.hibernate3.LocalSessionFactory"> <property name="configLocation"> <value>classpath:hibernate.cfg.xml</value> </property> </bean> <!-- 配置事务管理器 --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransaction"> <property name="sessionFactory"> <ref bean="sessionFactory"> </property> </bean> <!-- 配置事务的传播特性 --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="add*" propagation="REQUIRED"/> <tx:method name="del*" propagation="REQUIRED"/> <tx:method name="update*" propagation="REQUIRED"/> <tx:method name="*" read-only="true"/> </tx:attributes> </tx:advice> <!-- 哪些类的那些方法参与事务 --> <aop:config> <aop:pointcut id="allManagerMethod" expression="execution(* com.mycompany.usermgr.manager.*.*(..))"/> <aop:advisor point-ref="allManagerMethod" advice-ref="txAdvice"/> </aop:config>