最近整合使用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 整合使用,版本问题异常以及解决。的更多相关文章

  1. MVC中发生System.Data.Entity.Validation.DbEntityValidationException验证异常的解决方法

    发生System.Data.Entity.Validation.DbEntityValidationException这个异常的时候,如果没有用特定的异常类去捕捉,是看不到具体信息的. 通常都是用Sy ...

  2. ssh整合时报出的异常及解决办法

    com.opensymphony.xwork2.inject.DependencyException: com.opensymphony.xwork2.inject.ContainerImpl$Mis ...

  3. Redis-07.Spring Data整合Jedis

    Spring整合Jedis 1.单实例(想节约时间的请直接拖到下面跳过1.2部分) step1:毫无疑问,首先需要在pom.xml中配置Jedis依赖 <dependency> <g ...

  4. Java中Jedis操作Redis与Spring的整合

    Redis是一个key-value存储系统.它支持存储的value类型相对更多,包括string(字符串).list(链表).set(集合)和zset(有序集合).这些数据类型都支持push/pop. ...

  5. 【Spring】17、spring cache 与redis缓存整合

    spring cache,基本能够满足一般应用对缓存的需求,但现实总是很复杂,当你的用户量上去或者性能跟不上,总需要进行扩展,这个时候你或许对其提供的内存缓存不满意了,因为其不支持高可用性,也不具备持 ...

  6. spring和redis的整合

    spring和redis的整合-超越昨天的自己系列(7) 超越昨天的自己系列(7) 扯淡:  最近一直在慢慢多学习各个组件,自己搭建出一些想法.是一个涉猎的过程,慢慢意识到知识是可以融汇贯通,举一反三 ...

  7. Spring Boot + MyBatis + Druid + Redis + Thymeleaf 整合小结

    Spring Boot + MyBatis + Druid + Redis + Thymeleaf 整合小结 这两天闲着没事想利用**Spring Boot**加上阿里的开源数据连接池**Druid* ...

  8. spring 3.0 整合redis

    参考文章:https://blog.csdn.net/weixin_42184707/article/details/80361464 其中遇到了问题,第一,redis的xml配置文件中的,头部地址资 ...

  9. jedis,spring-redis-data 整合使用,版本问题异常

    jedis,spring-redis-data 整合使用,版本不匹配的时候经常会报一些异常,例如1: java.lang.NoClassDefFoundError: org/springframewo ...

随机推荐

  1. Java基础之扩展GUI——使用字体对话框(Sketcher 5 displaying a font dialog)

    控制台程序. 为了可以选择系统支持的字体,我们定义了一个FontDialog类: // Class to define a dialog to choose a font import java.aw ...

  2. 同事的游戏项目--Robocode-学习链接

    Robocode机器人库学习链接:http://www.pudn.com/search_db.asp?keyword=Robocode 官网 :http://robocode.sourceforge. ...

  3. sql 中实现往表中插入一条记录并返回当前记录的ID

    写一条存储过程,实现往User中插入一条记录并返回当前UserId(自增长id) --推荐写法 if(Exists(select * from sys.objects where name=N'Usp ...

  4. 关于linux中执行脚本或程序时指定的路径

    假设/mnt/bin 目录下存在一个名为 hello.sh 的可执行文件. 1. 若当前目录是 /mnt/bin ,可以使用 ./hello.sh 来执行这个可执行文件,但是使用 hello.sh 就 ...

  5. 使用AppCan实现分享网站功能

    使用AppCan实现分享网站功能 昨天我们实现了最基本的文字分享功能,今天呢,我们来实现基本的分享网站功能: 微信指引部分这里不再复述,具体请参见:http://newdocx.appcan.cn/i ...

  6. Android 开机启动

    创建一个Receiver,用来监听开机完毕: public class MyReceiver extends BroadcastReceiver { static final String actio ...

  7. php中rsa加密解密验证

    RSA非对称加密,对敏感的数据传输进行数据加密.验证等.测试环境:wamp.aliyun虚拟主机(lamp)一.加密解密的第一步是生成公钥.私钥对,私钥加密的内容能通过公钥解密(反过来亦可以).下载生 ...

  8. lucene5.5 field

    lucene常见Field IntField 主要对int类型的字段进行存储,需要注意的是如果需要对InfField进行排序使用SortField.Type.INT来比较,如果进范围查询或过滤,需要采 ...

  9. CentOS 7 安装、配置、使用 PostgreSQL 9.5及PostGIS2.2

    学习CentOS下安装使用PostgreSQL [安装过程] 1.添加RPM    yum install https://download.postgresql.org/pub/repos/yum/ ...

  10. Python多进程编程

    转自:Python多进程编程 阅读目录 1. Process 2. Lock 3. Semaphore 4. Event 5. Queue 6. Pipe 7. Pool 序. multiproces ...