- XML code
<bean id="dataSource" class="com.proj.ibatis.dataSource.DataSource" /> <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean" singleton="true"> <property name="dataSource"><ref local="dataSource"/></property> <property name="configLocation" value="classpath:com/proj/ibatis/sql-map-config.xml" /> </bean> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"></property> </bean> <bean name="userDao" class="com.proj.ibatis.dao.TUser"> <property name="sqlMapClient" ref="sqlMapClient" /> </bean> <!-- Service --> <bean id="userSerive" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager" ref="transactionManager"></property> <property name="target" ref="userDao"></property> <property name="transactionAttributes"> <props> <prop key="*">PROPAGATION_REQUIRED</prop> </props> </property> </bean>
在com.proj.ibatis.dao.TUser中
- Java code
User xx = new User(); xx.setUserid("hztest"); xx.setUsername("测试用户test"); userService.updUser(xx);
- Java code
public User updUser(User user) { getSqlMapClientTemplate().update("updUser", user); int i = 100/0; return user; }
理论上在执行到这里时,
- Java code
int i = 100/0;
请各位大侠帮我查查,是我配置有问题吗?
------解决方案--------------------
你要捕获,抛出异常
------解决方案--------------------
好像用 <prop key="*">PROPAGATION_REQUIRED,- exception</prop>