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 ...
随机推荐
- 如何在断开ssh连接后仍然保持服务器正常运行程序
问题描述:当SSH远程连接到服务器上,然后运行一个Python程序(bpr.py),然后把终端开闭(切断SSH连接)之后,发现该程序执行中断. 解决方法:使用nohup命令让程序在关闭窗口(切换SSH ...
- 全网扫描扫描10000端口后的优化脚本&域名列表指定端口的批量测试
方法一: #coding=utf-8 import urllib2 import threading from time import ctime,sleep print "Start-Ti ...
- 对java多线程的认识
多线程的概念:多线程是一种机制,它允许在程序中并发的执行多个线程,且每个线程间相互独立. 实现多线程的两种方式: 1.继承java.lang.Thread类,并且重写它的run方法,将线程的执行主体放 ...
- java权限修饰符
- 修改 window.setTimeout,使之可以传递参数和对象参数
/* 功能:修改 window.setTimeout,使之可以传递参数和对象参数 使用方法: setTimeout(回调函数,时间,参数1,,参数n) */ var _setTimeout=setTi ...
- java 除法向上,向下取整
向上取整用Math.ceil(double a) 向下取整用Math.floor(double a) // 举例: double a=35; double b=20; double c = a/b; ...
- python核心编程学习记录之条件和循环
- DDL、DML、DCL的理解
1.DDL 1-1.DDL的概述 DDL(Data Definition Language 数据定义语言)用于操作对象和对象的属性,这种对象包括数据库本身,以 ...
- calico docker 应用实例
在上一篇文章<quay.io/coreos/etcd 基于Docker镜像的集群搭建>中,介绍了ETCD集群的搭建.在此基础上,我们进一步实践calico docker的应用. PaaS ...
- spring事物配置,声明式事务管理和基于@Transactional注解的使用
http://blog.csdn.net/bao19901210/article/details/41724355 http://www.cnblogs.com/leiOOlei/p/3725911. ...