yml文件
mybatis:
mapper-locations: classpath:mapper/*Mapper.xml
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# 开启二级缓存
cache-enabled: true
# map-underscore-to-camel-case: true 驼峰功能
在Mapper接口上使用@CacheNamespace注解: 但是直接使用会报错
解决办法 在service上加上事务
@Transactional(rollbackFor = Exception.class)
加上之后还是报错为什么呢?是因为对象没有序列化,序列化一下实体对象就好
加上注解事务之后在手动抛出异常的时候发现没有exceotion时候怎么办
在catch里面手动加上回滚
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//回滚
// 或者
throw new RuntimeException(e.getMessage());