今天遇到个问题 ,本地环境就是启动不了,
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jedisConnectionFactory' defined in class path resource [config/applicationContext-redis.xml]: Cannot resolve reference to bean 'jedisPoolConfig' while setting bean property 'poolConfig'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jedisPoolConfig' defined in class path resource [config/applicationContext-redis.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'whenExhaustedAction' of bean class [redis.clients.jedis.JedisPoolConfig]: Bean property 'whenExhaustedAction' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
原因是:新版本的jedis中将maxActive改成了maxTotal , MaxWait改成了MaxWaitMillis
whenExhaustedAction改成了blockWhenExhausted
setWhenExhaustedAction替换成setBlockWhenExhausted。因为我们的目的是如果耗尽就抛异常,所以我们替换后参数设置为false就解决了。
<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig"> <property name="maxTotal" value="${redis.maxActive}"></property> <property name="maxIdle" value="${redis.maxIdle}"></property> <property name="MaxWaitMillis" value="${redis.maxWait}"></property> <property name="minEvictableIdleTimeMillis" value="${redis.pool.minEvictableIdleTimeMillis}"></property> <property name="numTestsPerEvictionRun" value="3"></property> <property name="timeBetweenEvictionRunsMillis" value="${redis.pool.timeBetweenEvictionRunsMillis}"></property> <property name="blockWhenExhausted" value="${redis.whenExhaustedAction}"></property> </bean>
参考:
https://blog.csdn.net/rbb317/article/details/45397155
https://blog.csdn.net/hzw2312/article/details/51512393