mybatis-redis

Spring Boot MyBatis 使用 Redis 作为二级缓存遇到的问题

拈花ヽ惹草 提交于 2019-11-29 09:39:59
在 Spring Boot MyBatis使用 Redis 作为二级缓存的时候,遇到了一个令人诡异的问题,在 MyBatis 从 Redis 中取出缓存并反序列的时候总是报这个错误 org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.ClassCastException: hello.entity.User cannot be cast to hello.entity.User java.lang.ClassCastException: hello.entity.User cannot be cast to hello.entity.User .... 根据异常可以看出是类型不匹配的异常,但是同样的类名,同样的字段,怎么就不匹配了呢? 我首先 MyBatis Redis cache 库是不是有BUG,已经它一直带着个 beta 的字眼,而且已经4年没更新了 <dependency> <groupId>org.mybatis.caches</groupId> <artifactId>mybatis-redis</artifactId> <version>1.0.0-beta2</version> <