<aop:aspectj-autoproxy proxy-target-class="true"/> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <aop:config> <aop:pointcut id="bussinessService" expression="execution(public * com.zchen.spring.dao.service..*.*(..))" /> <aop:advisor pointcut-ref="bussinessService" advice-ref="txAdvice" /> </aop:config> <tx:advice id="txAdvice" transaction-manager="txManager"> <tx:attributes> <tx:method name="save*" propagation="REQUIRED"/> <tx:method name="*" read-only="true" /> </tx:attributes> </tx:advice>
<!-- 当植入的类实现了接口时就要配置这个 -->
<aop:aspectj-autoproxy proxy-target-class="true"/>
我解释一下(* com.evan.crm.service.*.*(..))中几个通配符的含义:
第一个 * —— 通配 任意返回值类型
第二个 * —— 通配 包com.evan.crm.service下的任意class
第三个 * —— 通配 包com.evan.crm.service下的任意class的任意方法
第四个 .. —— 通配 方法可以有0个或多个参数
综上:包com.evan.crm.service下的任意class的具有任意返回值类型、任意数目参数和任意名称的方法
本文介绍了如何使用Spring框架进行事务管理的配置,包括定义事务管理器、切面、切入点及通知等,并详细解释了切入点表达式的含义。
8455

被折叠的 条评论
为什么被折叠?



