[redis.clients.jedis.JedisPoolConfig]: Bean property 'maxActive' is not writable or has an invalid

内容转自:http://blog.csdn.net/hzw2312/article/details/51512393


版本:

Jedis 2.5.2.jar,commons-pool2-2.0.jar

配置文件:

[html]  view plain  copy
  1. <bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig">  
  2.         <property name="maxIdle" value="${redis.maxIdle}" />  
  3.         <property name="maxActive" value="${redis.maxActive.value}" />  
  4.         <property name="maxWait" value="${redis.maxWait}" />  
  5.         <property name="testOnBorrow" value="${redis.testOnBorrow}" />  
  6. </bean>  

启动报错:

[plain]  view plain  copy
  1. 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener  
  2. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'poolConfig' defined in file [E:\Workspaces\eclipse\yfkj\yftms\redis\WebContent\WEB-INF\classes\applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'maxActive' of bean class [redis.clients.jedis.JedisPoolConfig]: Bean property 'maxActive' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?  
  3.     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1518)  
  4.     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1226)  
  5.     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)  
  6.     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)  
  7.     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)  
  8.     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)  
  9.     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)  
  10.     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)  
  11.     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)  
  12.     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)  
  13.     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)  
  14.     at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)  
  15.     at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)  
  16.     at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)  
  17.     at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5068)  
  18.     at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5584)  
  19.     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)  
  20.     at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1572)  
  21.     at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1562)  
  22.     at java.util.concurrent.FutureTask.run(Unknown Source)  
  23.     at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)  
  24.     at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)  
  25.     at java.lang.Thread.run(Unknown Source)  
  26. Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'maxActive' of bean class [redis.clients.jedis.JedisPoolConfig]: Bean property 'maxActive' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?  
  27.     at org.springframework.beans.BeanWrapperImpl.createNotWritablePropertyException(BeanWrapperImpl.java:231)  
  28.     at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:423)  
  29.     at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:280)  
  30.     at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:95)  
  31.     at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75)  
  32.     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1514)  
  33.     ... 22 more  

原因是:新版本的jedis中将maxActive改成了maxTotal , MaxWait改成了MaxWaitMillis

解决办法:

将改变了的属性替换掉就好:

[html]  view plain  copy
  1. <bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig">  
  2.         <property name="maxIdle" value="${redis.maxIdle}" />  
  3.         <!-- <property name="maxActive" value="${redis.maxActive.value}" />  
  4.         <property name="maxWait" value="${redis.maxWait}" /> -->  
  5.         <property name="maxTotal" value="${redis.maxActive.value}" />  
  6.         <property name="maxWaitMillis" value="${redis.maxWait}"></property>  
  7.         <property name="testOnBorrow" value="${redis.testOnBorrow}" />  
  8.     </bean>  

这样就能正常启动啦!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值