日期:2014-05-20  浏览次数:20612 次

spring事务配置的错误
XML code

<?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: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">
<!--  
    <aop:config>
    <aop:pointcut expression="execution(public String com.test.*.*.*(..))" id="pointcut"/>
        <aop:aspect id="aspect1" ref="aspectTest">
            <aop:before pointcut-ref="pointcut" method="before"/>
        </aop:aspect>
    </aop:config>
    <bean id="aspectTest" class="com.test.bean.AspectTest"/>
-->

<!-- <bean id="dataSource" class="org.springframework.jdbc.datasource" destroy-method="close">
    <property name="driverClass" value="com.mysql.jdbc.Driver"></property>
    <property name="jdbcUrl" value="jdbc:mysql://localhost/daisy"></property>
    <property name="user" value="root"></property>
    <property name="password" value="root"></property>
    <property name="maxPoolSize" value="40"></property>
    <property name="minPoolSize" value="1"></property>
    <property name="initialPoolSize" value="1"></property>
    <property name="maxIdleTime" value="20"></property>
</bean>
 -->
 
 
 
<!-- 定义数据源Bean,使用C3P0数据源实现 -->
<!-- <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
  destroy-method="close">
  <property name="driverClass" value="com.mysql.jdbc.Driver" />
  <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/daisy" />
  <property name="user" value="root" />
  <property name="password" value="root" />
  指定连接数据库连接池的最小连接数
  <property name="minPoolSize" value="10" />
  指定连接数据库连接池的最大连接数
  <property name="maxPoolSize" value="30" />
  指定连接数据库连接池的连接的最大空闲时间
  <property name="maxIdleTime" value="1800" />
  <property name="acquireIncrement" value="2" />
  <property name="maxStatements" value="0" />
  指定连接数据库连接池的初始化连接数
  <property name="initialPoolSize" value="2" />
  <property name="idleConnectionTestPeriod" value="1800" />
  <property name="acquireRetryAttempts" value="30" />
  <property name="breakAfterAcquireFailure" value="true" />
  <property name="testConnectionOnCheckout" value="false" />
 </bean> -->
 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> 
 <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/> 
 <property name="url" value="jdbc:mysql://localhost:3306/daisy"/> 
 <property name="username" value="root"></property> 
 <property name="password" value="root"></property> 
 <property name="initialSize" value="1"></property> 
 <property name="maxActive" value="500"></property> 
 <property name="maxIdle" value="2"></property> 
 <property name="minIdle" value="1"></property> 
 </bean> 
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource"></property>
</bean>

<bean id="tsa" class="com.daisy.dao.Transaction">
    <property name="ds" value="dataSource"></property>
</bean>

<tx:advice id="txAdvice" transaction-manager="transactionManager">/*错误提示:Error occured processing XML 'org/springframework/transaction/interceptor/TransactionInterceptor'. See Error Log for more details*/
    <tx:attributes>
        <tx:method name="*" propagation="REQUIRED" />
    </tx:attributes>
</tx:advice>

<aop:config>
    <aop:pointcut expression="* com.daisy.dao.Transaction.*(..)" id="daoCut"/>
    <aop:advisor advice-ref="txAdvice" pointcut-ref="daoCut"/>
</aop:config>
</beans>