今天对以前写的东西进行了部分整理,发现利用spring2.5的注释事物控制,好像只有一次成功过,那次使用的是JdbcTemplate。但是后来利用hibernate或者ibatis都没有成功,今天整理了很长时间,还是没有配置好。下面是写的一些xml文件,个人感觉应该没有什么问题了,疑惑。
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName"
value="com.mysql.jdbc.Driver" />
<property name="url"
value="jdbc:mysql://localhost/greatwall" />
<property name="username"
value="root" />
<property name="password"
value="sa" />
</bean>
<!-- ibatis sqlMapClient config
-->
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation">
<value>classpath:sql\sql-map-config.xml</value>
</property>
<property name="dataSource">
<ref bean="dataSource"
/>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource"
ref="dataSource" />
</bean>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<!-- all methods starting with 'get' are read-only
<tx:method name="select*"
read-only="true" /> -->
<!-- other methods use the default transaction
settings (see below) -->
<tx:method name="*"
/>
</tx:attributes>
</tx:advice>
<aop:aspectj-autoproxy />
<aop:config proxy-target-class="true"
/>
<!--
<aop:config proxy-target-class="true" >
<aop:pointcut id="fooServiceOperation"
expression="execution(* com.example.service.ICustomerService.*(..))"
/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="fooServiceOperation"
/>
</aop:config>
-->
<aop:config proxy-target-class="true"
>
<aop:advisor pointcut="execution(*
com.example.service.ICustomerService.*(..))" advice-ref="txAdvice"
/>
</aop:config>
<bean id="customerDAO" class="com.example.dao.impl.CustomerDAO">
<property name="sqlClient"
ref="sqlMapClient" />
</bean>
<bean id="customerService" class="com.example.service.impl.CustomerService">
<property name="customerDAO"
ref="customerDAO" />
</bean>