aop:config 事物的配置

aop:config 事物的配置

<?xml version="1.0" encoding="UTF-8"?>

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

        class="org.springframework.orm.hibernate3.HibernateTransactionManager"
        abstract="false" lazy-init="default" autowire="default"
        dependency-check="default">
       
           
       
   
   
       
           
           
           
           
            <!-- --&gt
       

   

   
                    expression="execution(* com.service.*.*(..))" />
                    pointcut-ref="allManagerMethod" />
   



另外一个例子的配置如下:

<?xml version="1.0" encoding="UTF-8"?>

"http://www.springframework.org/schema/beans"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xmlns:aop="http://www.springframework.org/schema/aop"

    xmlns:tx="http://www.springframework.org/schema/tx"

    xmlns:context="http://www.springframework.org/schema/context"

    xsi:schemaLocation="

http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-2.5.xsd

http://www.springframework.org/schema/tx

http://www.springframework.org/schema/tx/spring-tx-2.5.xsd

http://www.springframework.org/schema/aop

http://www.springframework.org/schema/aop/spring-aop-2.5.xsd

  http://www.springframework.org/schema/context  

   http://www.springframework.org/schema/context/spring-context-2.5.xsd

">

    "com.sxt"/>  

    <!-- 支持aop注解 --&gt

   

   

      

    "dataSource" 

            class="org.apache.commons.dbcp.BasicDataSource"

            "driverClassName" 

                value="com.mysql.jdbc.Driver"

             

            "url" value="jdbc:mysql://localhost:3306/myhib"

            "username" value="root"

            "password" value="123456">

     

 

   "sessionFactory" 

       class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"

           "dataSource"> 

               "dataSource" /> 

          

           "hibernateProperties"> 

                

                  <!-- key的名字前面都要加hibernate. --&gt

                   "hibernate.dialect"> 

                       org.hibernate.dialect.MySQLDialect 

                    

                   "hibernate.show_sql">true

                   "hibernate.hbm2ddl.auto">update

              

          

       "packagesToScan">

           com.sxt.po

      

    

 

"hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate" >

    "sessionFactory" ref="sessionFactory">

 

<!--配置一个JdbcTemplate实例--&gt 

"jdbcTemplate"  class="org.springframework.jdbc.core.JdbcTemplate">  

     "dataSource" ref="dataSource"/>  

 

 

 

<!-- 配置事务管理 --&gt

"txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" >

    "sessionFactory" ref="sessionFactory">

"txManager" />

    "execution(public * com.sxt.service.impl.*.*(..))" id="businessService"/>

    "txAdvice" pointcut-ref="businessService" />

"txAdvice" transaction-manager="txManager" >

   

       "find*"  read-only="true" propagation="NOT_SUPPORTED"  />

       <!-- get开头的方法不需要在事务中运行 。

       有些情况是没有必要使用事务的,比如获取数据。开启事务本身对性能是有一定的影响的--&gt

       "*"/>    <!-- 其他方法在实务中运行 --&gt

   

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29196873/viewspace-1132486/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29196873/viewspace-1132486/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值