@Transactional(readOnly = true) public void buyBook(Integer bookId, Integer userId) { //查询图书的价格 Integer price = bookDao.getPriceByBookId(bookId); //更新图书的库存 bookDao.updateStock(bookId); //更新用户的余额 bookDao.updateBalance(userId, price); //System.out.println(1/0); }...
-- timeout属性:设置事务的超时属性 --> <!-- propagation属性:设置事务的传播行为 --> <tx:method name="save*" read-only="false" rollback-for="java.lang.Exception" propagation="REQUIRES_NEW"/> <tx:method name="update*" read-only="false" rollback-for="java.lang.Exception" propagation="...
复制 packagecom.atguigu.spring6.bean;importorg.springframework.stereotype.Component;@ComponentpublicclassUser{publicUser(){System.out.println("run user");}} 6.1.5、测试 代码语言:javascript 复制 importcom.atguigu.spring6.bean.User;importorg.junit.jupiter.api.Test;importorg.junit.jupiter.api.extension...