第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

為什么沒(méi)有把事務(wù)綁定在一起 ,第一個(gè)還是修改了

@Service
public?class?TestServiceImpl?implements?TestService{
	
	@Resource
	private?TestDAO?testDAO;
	
	@Override
	@Transactional
	public?void?sql()?{
		Test?t1?=??new?Test();
			t1.setId(1L);
			t1.setNum(800);
		Test?t2?=??new?Test();
			t2.setId(2L);
			t2.setNum(1200);
		
		testDAO.update(t1);
		int?bug?=?1/0;
		testDAO.update(t2);
		
	}

}

<!-- 將事務(wù)與mySql關(guān)聯(lián) -->

? ? <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

? ? ? ? <property name="dataSource" ref="dataSource" />

? ? </bean>

? ??

? ? <!-- 事務(wù)注解驅(qū)動(dòng),標(biāo)注@Transactional的類和方法將具有事務(wù)性 -->

? ? <tx:annotation-driven transaction-manager="transactionManager"/>


正在回答

2 回答

applicationContext.xml

<tx:annotation-driven?/>
<context:component-scan?base-package="com.code"?/>

dispatcher-servlet.xml

<context:component-scan?base-package="com.code"?>
???<context:exclude-filter?type="annotation"?expression="org.springframework.stereotype.Service"?/>
</context:component-scan>
package?com.code.service.impl;

import?javax.annotation.Resource;

import?org.springframework.stereotype.Service;
import?org.springframework.transaction.annotation.Transactional;

import?com.code.dao.TestDAO;
import?com.code.entity.Test;
import?com.code.service.TestService;

@Service
public?class?TestServiceImpl?implements?TestService{
	
	@Resource
	private?TestDAO?testDAO;
	
	@Override
	@Transactional
	public?void?sql()?{
		Test?t1?=??new?Test();
			t1.setId(1L);
			t1.setNum(800);
		Test?t2?=??new?Test();
			t2.setId(2L);
			t2.setNum(1200);
		
		testDAO.update(t1);
		int?bug?=?1/0;
		testDAO.update(t2);
		
	}

}

已解決。都沒(méi)人回復(fù)我 ?好失望。。。

0 回復(fù) 有任何疑惑可以回復(fù)我~

springMVC + mybits + mysql

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

為什么沒(méi)有把事務(wù)綁定在一起 ,第一個(gè)還是修改了

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)