随笔 - 16  文章 - 0  trackbacks - 0
<2012年3月>
26272829123
45678910
11121314151617
18192021222324
25262728293031
1234567

常用链接

留言簿

随笔档案

友情链接

搜索

  •  

最新评论

阅读排行榜

评论排行榜

<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
 xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
 xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-3.1.xsd        
           http://www.springframework.org/schema/aop
           http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
           http://www.springframework.org/schema/tx
           http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">

 <!-- 拦截配置 -->
 <tx:advice id="txAdvice" transaction-manager="transactionManager">
      <tx:attributes>
            <!--说明事务类别 read-only表示不支持事务,propagation的事务类别与EJB保持一致-->
           <tx:method name="find*" read-only="true" />
           <tx:method name="get*" read-only="true" />
           <tx:method name="load*" read-only="true" />
           <tx:method name="save*" propagation="REQUIRED" />
           <tx:method name="insert*" propagation="REQUIRED" />
           <tx:method name="update*" propagation="REQUIRED" />
           <tx:method name="delete*" propagation="REQUIRED" />
           <tx:method name="*" propagation="REQUIRED" />
      </tx:attributes>
 </tx:advice>

 <!-- 切入点 -->
 <aop:config>
      <!-- Dao层事务 说明你要拦截那些包下面的类的方法-->
      <aop:advisor id="daoTx" advice-ref="txAdvice"  pointcut="execution(* *..dao.impl.*.*(..))" order="0" />
      <!-- service层事务 -->
      <aop:advisor id="serviceTx" advice-ref="txAdvice"  pointcut="execution(* *..service.impl.*.*(..))" order="1" />
 </aop:config>

 <!-- Enable @Transactional support -->
 <tx:annotation-driven />
 
 <!-- 事务管理 -->
 <bean id="transactionManager"  class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
      <property name="dataSource" ref="dataSource" />
 </bean>
。。。下面是具体的dataSource配置
或下载附件http://www.blogjava.net/Files/yiqi/application-resources.rar

posted on 2012-03-13 10:56 民工二代 阅读(296) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: