spring-mybatis 事物配置 execution表达式含义
1、
<!-- 扫描service包下所有使用注解的类型 --> <context:component-scan base-package="com.yongjun.edu.service" /> <!-- 配置事务管理器 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <!-- 注入数据库连接池 --> <property name="dataSource" ref="dataSource" /> </bean> <!--配置事务的通知:(事务的增强)--> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <!-- propagation :事务传播行为 isolation :事务的隔离级别 read-only :只读 rollback-for :发生哪些异常回滚 no-rollback-for :发生哪些异常不回滚 timeout :过期信息 --> <tx:method name="store*" propagation="REQUIRED" read-only="false"/> <tx:method name="delete*" propagation="REQUIRED" read-only="false"/> <tx:method name="add*" propagation="REQUIRED" read-only="false"/> <tx:method name="save*" propagation="REQUIRED" read-only="false"/> <tx:method name="update*" propagation="REQUIRED" read-only="false"/> <tx:method name="load*" propagation="REQUIRED" read-only="true"/> <tx:method name="get*" propagation="REQUIRED" read-only="true"/> <tx:method name="*" propagation="REQUIRED" read-only="true" rollback-for="Exception"/> </tx:attributes> </tx:advice> <!--配置切面--> <aop:config> <!--配置切入点--> <aop:pointcut id="doService" expression="execution(* com.yongjun.edu.service..*.*(..))"/> <!--配置切面--> <aop:advisor advice-ref="txAdvice" pointcut-ref="doService"/> </aop:config>
execution(* com.yongjun.edu.service..*.*(..)) 含义如下: