开发中遇到的一些异常

具体异常信息:

org.springframework.dao.InvalidDataAccessApiUsageException:

            No EntityManager with actual transactionavailable for current thread - cannot reliably process 'persist' call;

           nested exception isjavax.persistence.TransactionRequiredException: No EntityManager with actualtransaction available for current thread - cannot reliably process 'persist'call

       

以上这个异常可能是由于在需要事务的方法上,没有开启事务,结果就操作需要事务的方法比如保存,修改数据库数据方法。

修复方式也特别简单,在需要事务的方法上加入加上注解:@Transactional即可。

posted on 2020-05-14 16:42  只挣朝夕  阅读(348)  评论(0编辑  收藏  举报