Spring Data Redis (バージョン: 1.1.x) を使用して redis クライアント (レタス クライアント バージョン: 2.3.3) の接続ファクトリをセットアップしようとしていますが、すべてを配線する際に問題が発生しています。
ここに私の設定があります: application-context-redis.xml
<bean id="lettuceConnectionFactory"
class="org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory">
<constructor-arg index="0" ref="redisPool"/>
</bean>
<bean id="redisPool"
class="org.springframework.data.redis.connection.lettuce.DefaultLettucePool">
<constructor-arg index="0" value="${redis.host}" />
<constructor-arg index="1" value="${redis.port}"/>
<constructor-arg index="2" ref="#{redisPoolConfig.Config}"/>
</bean>
<bean id="redisPoolConfig" class="org.apache.commons.pool.impl.GenericObjectPool"
p:maxActive="${redis.maxActive}"
p:maxIdle="${redis.maxIdle}"
p:minIdle="${redis.minIdle}"
p:maxWait="${redis.maxWait}"
p:testOnBorrow="${redis.testOnBorrow}"
p:testOnReturn="${redis.testOnReturn}"
p:testWhileIdle="${redis.testWhileIdle}"
p:whenExhaustedAction="${redis.whenExhaustedAction}"
p:timeBetweenEvictionRunsMillis="${redis.timeBetweenEvictionRunsMillis}"
p:numTestsPerEvictionRun="${redis.numTestsPerEvictionRun}"
p:softMinEvictableIdleTimeMillis="${redis.softMinEvictableIdleTimeMillis}"
p:minEvictableIdleTimeMillis="${redis.minEvictableIdleTimeMillis}"/>
/>
<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate"
p:connectionFactory-ref="lettuceConnectionFactory"/>
これはredisPool Beanのコンストラクタ シグネチャです。
public DefaultLettucePool(String hostName, int port, Config poolConfig) {
this.hostName = hostName;
this.port = port;
this.poolConfig = poolConfig;
}
poolConfigプロパティはpublic内部静的クラスです: org.apache.commons.pool.impl.GenericObjectPool.Config
Configプロパティは静的な内部クラス (こちらを参照)であり、getter メソッドが含まれていないため、redisPool Bean に注入するのに苦労しています。
これは私が得ているエラーです:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisPool' defined in class path resource [application-context-redis.xml]: Cannot resolve reference to bean '#{redisPoolConfig.Config}' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 16): Field or property 'Config' cannot be found on object of type 'org.apache.commons.pool.impl.GenericObjectPool'
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:615)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1045)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:949)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:323)
... 72 more
Caused by: org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 16): Field or property 'Config' cannot be found on object of type 'org.apache.commons.pool.impl.GenericObjectPool'
at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:142)
at org.springframework.beans.factory.support.AbstractBeanFactory.evaluateBeanDefinitionString(AbstractBeanFactory.java:1312)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.evaluate(BeanDefinitionValueResolver.java:225)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:312)
... 84 more