spring整合jedis没有maxActive和maxWait对应setter方法报错
2016-11-23 17:30
447 查看
下午闲来无事自己动手集成spring和redis,参考网上的博客配置好了Spring配置文件,做单元测试启动时结果一直
报错,“maxWait”和“maxActive”属性值非法,接着排查到底是哪里的问题?
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'maxWait' of bean class [redis.clients.jedis.JedisPoolConfig]: Bean property 'maxWait' is not writable or has an invalid setter method.
Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.createNotWritablePropertyException(BeanWrapperImpl.java:230)
at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:423)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75)
at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:280)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:95)
... 74 more
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1514)
从报错看出maxWait没有setter方法
上述问题其实没怎么花时间就解决了,本来没有下载spring的源码,由于maven用起来蛮方便的,点进去自动下载,
所以很快下载我所用的jedisPoolConfig中并没有“maxWait”和“maxActive”属性值,因此就不能配置这两个属性
值了,问题自然而然也就解决了。
这里,我的jedis版本是
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.8.2</version>
</dependency>
这个版本所依赖的commns-pool版本是commons-pool2-2.4.2.jar
![](https://img-blog.csdn.net/20161123175937227?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
![](https://img-blog.csdn.net/20161123180008056?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
![](https://img-blog.csdn.net/20161123180012149?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
原来Apache 在2.0版本以上已经做了一次升级
那之前的旧版本肯定没问题了,查看源码JedisPoolConfig继承至
org.apache.commons.pool.impl.GenericObjectPool.Config
能够看到之前会报错的maxActive和maxWait属性。
那么新版本替换成了什么呢
通过这个链接,我们知道commons-pool2 的maxactive,maxWait已经更改命名。
点击打开链接
dbcp的修改日志显示:change “maxActive” -> “maxTotal” and “maxWait” -> “maxWaitMillis”
所以高版本jedis配置JedisPoolConfig的maxActive,maxWait应该为:
报错,“maxWait”和“maxActive”属性值非法,接着排查到底是哪里的问题?
<bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig"> <property name="maxIdle" value="${redis.maxIdle}" /> <property name="maxActive" value="${redis.maxActive}" /> <property name="maxWait" value="${redis.maxWait}" /> <property name="testOnBorrow" value="${redis.testOnBorrow}" /> </bean>
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'maxWait' of bean class [redis.clients.jedis.JedisPoolConfig]: Bean property 'maxWait' is not writable or has an invalid setter method.
Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.createNotWritablePropertyException(BeanWrapperImpl.java:230)
at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:423)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75)
at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:280)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:95)
... 74 more
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1514)
从报错看出maxWait没有setter方法
上述问题其实没怎么花时间就解决了,本来没有下载spring的源码,由于maven用起来蛮方便的,点进去自动下载,
所以很快下载我所用的jedisPoolConfig中并没有“maxWait”和“maxActive”属性值,因此就不能配置这两个属性
值了,问题自然而然也就解决了。
这里,我的jedis版本是
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.8.2</version>
</dependency>
这个版本所依赖的commns-pool版本是commons-pool2-2.4.2.jar
原来Apache 在2.0版本以上已经做了一次升级
那之前的旧版本肯定没问题了,查看源码JedisPoolConfig继承至
org.apache.commons.pool.impl.GenericObjectPool.Config
能够看到之前会报错的maxActive和maxWait属性。
那么新版本替换成了什么呢
通过这个链接,我们知道commons-pool2 的maxactive,maxWait已经更改命名。
点击打开链接
dbcp的修改日志显示:change “maxActive” -> “maxTotal” and “maxWait” -> “maxWaitMillis”
所以高版本jedis配置JedisPoolConfig的maxActive,maxWait应该为:
<bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig"> <property name="maxIdle" value="${redis.maxIdle}" /> <property name="maxTotal" value="${redis.maxTotal}" /> <property name="maxWaitMillis" value="${redis.maxWaitMillis}" /> <property name="testOnBorrow" value="${redis.testOnBorrow}" /> </bean>
相关文章推荐
- jedis高版本的JedisPoolConfig没有maxActive和maxWait
- spring-data-redis整合jedis对应版本
- jedis高版本的JedisPoolConfig没有maxActive和maxWait
- jedis高版本的JedisPoolConfig没有maxActive和maxWait
- Redis_jedis高版本的JedisPoolConfig没有maxActive和maxWait
- shiro和Spring整合使用注解时没有执行realm的doGetAuthorizationInfo回调方法的解决
- Redis之——jedis高版本的JedisPoolConfig没有maxActive和maxWait
- shiro和Spring整合使用注解时没有执行realm的doGetAuthorizationInfo回调方法的解决
- Redis之——jedis高版本的JedisPoolConfig没有maxActive和maxWait
- jedis高版本的JedisPoolConfig没有maxActive和maxWait
- Spring2.5,Activemq5.2整合遇到的问题以及解决方法
- Struts1.整合Spring的三种方法
- spring整合struts时创建ApplicationContext的方法
- Struts1.整合Spring的三种方法
- Struts ,Hibernate ,Spring 常用整合配置方法.
- Struts+hibernate+Spring的整合方法
- strut1.X和spring整合的二种方法
- spring+hibernate+struts 整合的三种方法,我只用第三种可以。
- 整合Spring与Struts的几种方法
- Spring整合Struts1.X的三种方法