最近整合使用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. svg学习(七)polygon

    <polygon> 标签用来创建含有不少于三个边的图形. <?xml version="1.0" standalone="no"?> & ...

  2. 虚拟主机无法使用fsockopen操作处理方法

    一.如何禁用fsockopen()下面是两种常用的禁用fsockopen的方法.1.修改php.ini,将 disable_functions = 后加入 fsockopen2.修改php.ini,将 ...

  3. js图片放大镜

    <!doctype html><html><head><meta charset="utf-8"><style>#sma ...

  4. laravel框架总结(七) -- 数据库操作

      1.使用DB门面进行基本操作 一旦你设置好了数据库连接,就可以使用 DB facade 来进行查找.DB facade 提供每个类型的查找方法:select.update.insert.delet ...

  5. 类函数和对象函数 PHP

    1. bool class_exists ( string $class_name [, bool $autoload = true ] )  检查指定的类是否已定义. 如果由 class_name  ...

  6. printf("%*s%s%*s",——)是什么?

    我们可能知道scanf里用*修饰符,是起到过滤读入的作用.比如一个有三列数值的数据,我只想得到第2列数值,可以在循环里用scanf(“%*d%d%*d”, a[i])来读入第i行的第2个数值到a[i] ...

  7. linux chomd 学习

    chomd -R 777 directory_name :递归地给directory目录下所有文件和子目录的属主分配读的权限 ------2016-10-31 -- source: Linux chm ...

  8. Logistic 分类器与 softmax分类器

    首先说明啊:logistic分类器是以Bernoulli(伯努利) 分布为模型建模的,它可以用来分两种类别:而softmax分类器以多项式分布(Multinomial Distribution)为模型 ...

  9. [css]需警惕CSS3属性的书写顺序

    转载张鑫旭:http://www.zhangxinxu.com/wordpress/2010/09/%E9%9C%80%E8%AD%A6%E6%83%95css3%E5%B1%9E%E6%80%A7% ...

  10. Postman 安装及使用入门教程

    安装 本文只是基于 Chrome 浏览器的扩展插件来进行的安装,并非单独应用程序. 首先,你要台电脑,其次,安装有 Chrome 浏览器,那你接着往下看吧. 1. 官网安装(别看) 打开官网,http ...