Spring mvc 3.2 整合 事务 与 log4j

spring-config.xml

<context:property-placeholder ignore-resource-not-found="true" location="classpath:/db.properties,log4j.properties"/>
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
      <property name="dataSource" ref="dataSource"/>
    </bean>
    <aop:config>
      <aop:pointcut id="serviceOperation" expression="execution(* com.lee.web.services.*.*(..))"/>
      <aop:advisor pointcut-ref="serviceOperation" advice-ref="txAdvice"/>
    </aop:config>
    <tx:advice id="txAdvice" transaction-manager="txManager">
      <tx:attributes>
        <tx:method name="add*" propagation="REQUIRED"/>
        <tx:method name="update*" propagation="REQUIRED"/>
        <tx:method name="remove*" propagation="REQUIRED"/>
        <tx:method name="*" read-only="true" rollback-for="SQLException"/>
      </tx:attributes>
    </tx:advice>


事务需要添加的jar

com.springsource.org.aopalliance-1.0.0.jar

com.springsource.org.aspectj.weaver-1.7.2.RELEASE.jar

http://ebr.springsource.com/repository/app/bundle/version/detail?name=com.springsource.org.aopalliance&version=1.0.0&searchType=bundlesBySymbolicName&searchQuery=aopalliance


http://ebr.springsource.com/repository/app/bundle/version/detail?name=com.springsource.org.aspectj.weaver&version=1.7.2.RELEASE&searchType=bundlesBySymbolicName&searchQuery=aspectj.weaver


log4j.properties

log4j.rootLogger=ERROR, log
log4j.appender.log=org.apache.log4j.DailyRollingFileAppender
log4j.appender.log.file=C:/logs/test.log
log4j.appender.log.layout=org.apache.log4j.PatternLayout
log4j.appender.log.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{2}:%L - %m%n
log4j.category.org.springframework.beans.factory=DEBUG


你可能感兴趣的:(spring,log4j,事务)