0
点赞
收藏
分享

微信扫一扫

Redis使用opsFor系列 get读取报错InvocationTargetException


说明

昨天还好好的redis取值突然报错,抛出的异常是风马牛不相及的 InvocationTargetException ,找了好久的原因,打了好久的断点,查了好久的百度,依然一无所获。。。

最后自己都不知道是哪个关键词找到的这篇文章: RedisTemplate先在事务中使用,然后在非事务中使用,导致读操作不能立即读出数据

正好是我的问题所在,但是大神码文的时候这个关键词定的实在是。。我要知道是事务的锅,我还要来搜索嘛?

所以有了此文,算是作为一个查错的搜索入口吧,标题帮大家定的明确一些。如有需要,请点击上述链接前往拜读。

报错信息

org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.IllegalAccessError: class org.springframework.data.redis.core.$Proxy174 cannot access its superinterface org.springframework.data.redis.core.RedisConnectionUtils$RedisConnectionProxy

Caused by: java.lang.IllegalAccessError: class org.springframework.data.redis.core.$Proxy174 cannot access its superinterface org.springframework.data.redis.core.RedisConnectionUtils$RedisConnectionProxy

原因

RedisTemplate先在事务中使用,然后在非事务中使用,导致读操作不能立即读出数据

解决方案

将@Transactional注解注释掉即可

Redis使用opsFor系列 get读取报错InvocationTargetException_java

举报

相关推荐

0 条评论