jedis,spring-redis-data 整合使用,版本问题异常以及解决。
最近整合使用redis spring-redis 出现了一下问题
spring:3.2.4.RELEASE
jedis: jedis 2.4.2
spring-data-redis: 1.5.2.RELEASE
各种折腾换了N个版本之后,启动的时候报错主要有一下两种:
Exception in thread "main" java.lang.NoSuchMethodError: org.springframework.util.ClassUtils.isUserLevelMethod(Ljava/lang/reflect/Method;)Z
java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
org/springframework/data/redis/connection/jedis/JedisConnectionFactory.afterPropertiesSet()V
最后得到如下配置是OK的:
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.4.2</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>1.3.0.RELEASE</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-xxx</artifactId>
<version>3.2.4.RELEASE</version>
</dependency>
版本问题解决了,先贴各项配置代码:
spring:
<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
<property name="maxTotal" value="32"></property>
<property name="maxIdle" value="6"></property>
<property name="testOnBorrow" value="true" />
</bean> <bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory" destroy-method="destroy">
<property name="poolConfig" ref="jedisPoolConfig"></property>
<property name="hostName" value="123.56.72.172"></property>
<property name="port" value="6379"></property>
<property name="password" value="redis"></property>
<property name="timeout" value="15000"></property>
<property name="usePool" value="true"></property>
</bean>
<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
<property name="connectionFactory" ref="jedisConnectionFactory"></property>
<property name="keySerializer">
<bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
</property>
<property name="valueSerializer">
<bean class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer"/>
</property>
</bean>
注入:
@Autowired
private RedisTemplate<String, String> redisTemplate;
使用:
String paramK = "spring-redis-key";
String paramV ="Hello,spring-redis-data!!!";
redisTemplate.opsForValue().set(paramK, paramV);
存值成功之后,存的值为:
this ok.
在 redis-cli中查看值结果如下:
get spring-redis-key
"\xac\xed\x00\x05t\x00\bthis ok."
发现没,多了一个前缀 \xac\xed\x00\x05t\x00\b
这个为序列化的问题:http://blog.csdn.net/yunhaibin/article/details/9001198
参考资料:
http://zhaobing315.iteye.com/blog/2082189
http://www.cnblogs.com/tankaixiong/p/3660075.html
http://www.sxt.cn/u/2839/blog/4363
http://www.cnblogs.com/tankaixiong/p/3660075.html
jedis,spring-redis-data 整合使用,版本问题异常以及解决。的更多相关文章
- MVC中发生System.Data.Entity.Validation.DbEntityValidationException验证异常的解决方法
发生System.Data.Entity.Validation.DbEntityValidationException这个异常的时候,如果没有用特定的异常类去捕捉,是看不到具体信息的. 通常都是用Sy ...
- ssh整合时报出的异常及解决办法
com.opensymphony.xwork2.inject.DependencyException: com.opensymphony.xwork2.inject.ContainerImpl$Mis ...
- Redis-07.Spring Data整合Jedis
Spring整合Jedis 1.单实例(想节约时间的请直接拖到下面跳过1.2部分) step1:毫无疑问,首先需要在pom.xml中配置Jedis依赖 <dependency> <g ...
- Java中Jedis操作Redis与Spring的整合
Redis是一个key-value存储系统.它支持存储的value类型相对更多,包括string(字符串).list(链表).set(集合)和zset(有序集合).这些数据类型都支持push/pop. ...
- 【Spring】17、spring cache 与redis缓存整合
spring cache,基本能够满足一般应用对缓存的需求,但现实总是很复杂,当你的用户量上去或者性能跟不上,总需要进行扩展,这个时候你或许对其提供的内存缓存不满意了,因为其不支持高可用性,也不具备持 ...
- spring和redis的整合
spring和redis的整合-超越昨天的自己系列(7) 超越昨天的自己系列(7) 扯淡: 最近一直在慢慢多学习各个组件,自己搭建出一些想法.是一个涉猎的过程,慢慢意识到知识是可以融汇贯通,举一反三 ...
- Spring Boot + MyBatis + Druid + Redis + Thymeleaf 整合小结
Spring Boot + MyBatis + Druid + Redis + Thymeleaf 整合小结 这两天闲着没事想利用**Spring Boot**加上阿里的开源数据连接池**Druid* ...
- spring 3.0 整合redis
参考文章:https://blog.csdn.net/weixin_42184707/article/details/80361464 其中遇到了问题,第一,redis的xml配置文件中的,头部地址资 ...
- jedis,spring-redis-data 整合使用,版本问题异常
jedis,spring-redis-data 整合使用,版本不匹配的时候经常会报一些异常,例如1: java.lang.NoClassDefFoundError: org/springframewo ...
随机推荐
- 20145320《Java程序设计》第一次实验报告
20145320<Java程序设计>第一次实验报告 北京电子科技学院(BESTI)实验报告 课程:Java程序设计 班级:1453 指导教师:娄嘉鹏 实验日期:2016.04.08 18: ...
- 自动化环境robot framework安装中问题解决
在搭建自动化环境的时候需要安装以下程序:
- Linux入门:运行级别解析
Linux入门:运行级别解析 一.查看当前运行级别 Ubuntu中,runlevel命令 可以查看当前运行级别: CentOS中,who -r 命令查看当前运行级别: www.2cto.com ...
- JS中同名函数有效执行顺序
html中如果出现函数同名时:如果有多个外部引入的js文件,例如a.js和b.js(引入顺序假定是a.js,然后是b.js),同时html中本身也有内部的js.那么针对 出现函数名一样的情况时,无论他 ...
- Cutterman 切图神器,虽然还没用过,先 mark 一下好了
在官网上找了半天也没发现下载链接,注册账号用无法激活,还是等等再试吧.
- Jenkins入门系列之——01第一章 Jenkins是什么?
第一章 Jenkins是什么? Jenkins 是一个可扩展的持续集成引擎. 主要用于: l 持续.自动地构建/测试软件项目. l 监控一些定时执行的任务. Jenkins拥有的特性包括: l 易于安 ...
- Shell.xaml
<Window x:Class="HelloWorld.Shell" xmlns="http://schemas.microsoft.com/winfx/2006/ ...
- 制作登录界面,登录成功后把用户名放在session里,在第3个页面读取session显示用户名
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...
- jquery.validate使用 - 1
jquery.validate使用攻略 好几年不写JS了,资料整理起来比较慢,格式也有点乱 主要分几部分jquery.validate 基本用法jquery.validate API说明jquery. ...
- 关于token的杂记
http://www.cnblogs.com/xiekeli/p/5607107.html https://www.oschina.net/question/1264088_220768 token作 ...