异常信息:
Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: Class com.jfinal.aop.Callback does not implement Serializable or externalizable at com.jfinal.plugin.redis.serializer.FstSerializer.valueToBytes(FstSerializer.java:60) at com.jfinal.plugin.redis.Cache.valueToBytes(Cache.java:1213) at com.jfinal.plugin.redis.Cache.setex(Cache.java:78) at com.admin.config.kit.RedisKit.putByCache(RedisKit.java:39) at com.admin.config.kit.RedisKit.get(RedisKit.java:29) at com.admin.config.kit.RedisKit.get(RedisKit.java:35) at com.admin.config.kit.Test.main(Test.java:46)
代码:
QlStudent server = Aop.get(QlStudent.class); Map<Object, Object> s= RedisKit.get("fceb7f2da7f14623b61f45871dab585a", 20, new IDataLoader() { @Override public Object load() { return server.findFirst("select * from ql_student where student_id='fceb7f2da7f14623b61f45871dab585a'"); } }); System.out.println(s);
RedisKit
public static <T> T get(Object key, int seconds, IDataLoader dataLoader) { Cache cache = Redis.use(); Object data = cache.get(key); if (data == null) { data = dataLoader.load(); put(cache, key, data, seconds); } return (T)data; } 只有用server.find... 这种方式就会报序列化的错误,但是用DB.find...又没问题,因为项目中绝大部分用的都是server.find这种查询,如果全改的话,工作量太大,而且测试工作量也巨大,有没有办法让这两种查询方法都可以使用?