Как настроить пароль (xml) spring-data-redis-1.7.2, когда я использую кластер redis? - PullRequest
0 голосов
/ 26 сентября 2018

Я пытаюсь использовать spring-data-redis-2.0.9, я настраиваю пароль вот так, все правильно.

<bean name="redisPassword" class="org.springframework.data.redis.connection.RedisPassword">
    <constructor-arg name="thePassword" value="${spring.redis.cluster.password}"/>
</bean>

<bean id="redisClusterConfiguration" class="org.springframework.data.redis.connection.RedisClusterConfiguration">
    <constructor-arg name="propertySource" ref="propertySource"/>
    <property name="password" ref="redisPassword"/>
</bean>

Но по какой-то причине я должен использовать spring-data-redis-1.7.2. Вот моя конфигурация

<context:property-placeholder location="/WEB-INF/redis.properties" ignore-unresolvable="true"></context:property-placeholder>

<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
    <property name="maxTotal" value="${redis.pool.maxTotal}"/>
    <property name="maxIdle" value="${redis.pool.maxIdle}"/>
    <property name="numTestsPerEvictionRun" value="${redis.pool.numTestsPerEvictionRun}"/>
    <property name="timeBetweenEvictionRunsMillis" value="${redis.pool.timeBetweenEvictionRunsMillis}"/>
    <property name="minEvictableIdleTimeMillis" value="${redis.pool.minEvictableIdleTimeMillis}"/>
    <property name="softMinEvictableIdleTimeMillis" value="${redis.pool.softMinEvictableIdleTimeMillis}"/>
    <property name="maxWaitMillis" value="${redis.pool.maxWaitMillis}"/>
    <property name="testOnBorrow" value="${redis.pool.testOnBorrow}"/>
    <property name="testWhileIdle" value="${redis.pool.testWhileIdle}"/>
    <property name="blockWhenExhausted" value="${redis.pool.blockWhenExhausted}"/>
</bean>

<bean name="propertySource" class="org.springframework.core.io.support.ResourcePropertySource">
    <constructor-arg name="resource" value="/WEB-INF/redis.properties" />
</bean>

<bean id="redisClusterConfig" class="org.springframework.data.redis.connection.RedisClusterConfiguration">
    <constructor-arg name="propertySource" ref="propertySource"/>
</bean>

<bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
    <constructor-arg name="clusterConfig" ref="redisClusterConfig"/>
    <constructor-arg name="poolConfig" ref="jedisPoolConfig"/>
    <property name="timeout" value="${redis.timeout}"/>
    <property name="password" value="spring.redis.cluster.password" />
</bean>

<bean id="keySerializer" class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
<bean id="valueSerializer" class="org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer"/>

<bean id = "redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
    <property name="connectionFactory" ref="jedisConnectionFactory" />
    <property name="keySerializer" ref="keySerializer" />
    <property name="valueSerializer" ref="valueSerializer" />
    <property name="hashKeySerializer" ref="valueSerializer" />
    <property name="hashValueSerializer" ref="valueSerializer" />
</bean>

<bean id="stringRedisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate">
    <constructor-arg name="connectionFactory" ref="jedisConnectionFactory"></constructor-arg>
    <property name="keySerializer" ref="keySerializer" />
    <property name="valueSerializer" ref="valueSerializer" />
    <property name="hashKeySerializer" ref="valueSerializer" />
    <property name="hashValueSerializer" ref="valueSerializer" />
</bean>

tomcat напоминает мне "Jedis не поддерживает защищенные паролем конфигурации Redis Cluster".Как настроить пароль spring-data-redis-1.7.2.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...