单元测试@Test加@Transactional注解自动回滚
1.今天在做单元测试在test注解加了@Transactional发现事务自动回滚了
JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@60510791] will be managed by Spring
==> Preparing: INSERT INTO item ( title, sell_point, price, num, image, cid, brand ) VALUES ( ?, ?, ?, ?, ?, ?, ? )
==> Parameters: 奔驰s400(String), 双排气(String), 666666.99(Double), 5(Integer), https://www.mercedes-benz.com.cn/?smtid=570962679z32cmz2dt02z1pdz0z(String), 6(Long), 奔驰(String)
<== Updates: 1
Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@73476e2d]
Transaction synchronization deregistering SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@73476e2d]
Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@73476e2d]
2019-10-13 20:45:16.457 INFO 15948 --- [ main] o.s.t.c.transaction.TransactionContext : Rolled back transaction for test: [DefaultTestContext@42bc14c1 testClass = EsDemoTest01, testInstance = com.ls.EsDemoTest01@2823b7c5,
2.加入 @Rollback(false)注解可以正常插入,但是若抛出异常,也正常插入,事务均不回滚