当你的事务未开启时候
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3e1fd62b] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@e280403] will not be managed by Spring
未开启,未被Spring管理,则会有上面的提示。
@Test
@Transactional
public void selectWebsitesById() {
Websites websites = websitesService.selectWebsitesById(1);
log.info(websites.toString());
System.out.println("======================");
websites = websitesService.selectWebsitesById(1);
log.info(websites.toString());
}
我这边测试的一级缓存,如果未开启事务,会出现两次重复查询,也就是一级缓存没有起作用,加了事务,就可以了。
加了之后的