方式1

<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    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.0.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
    <import resource="classpath:applicationContext-dao.xml" />
    <bean id="bbtForum"
        class="com.baobaotao.service.impl.BbtForumImpl"
        p:forumDao-ref="forumDao"
        p:topicDao-ref="topicDao"
        p:postDao-ref="postDao"/>

    
    <bean id="transactionManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
        p:dataSource-ref="dataSource"/>

    <aop:config>
        <aop:pointcut id="serviceMethod"
            expression="execution(* com.baobaotao.service.*Forum.*(..))" />
        <aop:advisor pointcut-ref="serviceMethod"
            advice-ref="txAdvice" />
    </aop:config>
    <tx:advice id="txAdvice" >
        <tx:attributes> 
            <tx:method name="get*" read-only="false"/>
            <tx:method name="add*" rollback-for="PessimisticLockingFailureException"/>
            <tx:method name="update*"/>         
        </tx:attributes>
    </tx:advice>
</beans>
View Code

相关文章:

  • 2022-12-23
  • 2022-01-28
  • 2022-12-23
  • 2021-05-30
  • 2021-11-20
  • 2021-12-01
  • 2021-08-24
猜你喜欢
  • 2021-05-29
  • 2021-08-19
  • 2022-12-28
  • 2022-12-23
  • 2022-12-23
  • 2021-06-20
  • 2021-07-18
相关资源
相似解决方案