spring配置
redis.host1=192.168.139.31
redis.port1=7000
redis.password1=
redis.host2=192.168.139.31
redis.port2=7001
redis.password2=
redis.host3=192.168.139.31
redis.port3=7002
redis.password2=
redis.host4=192.168.139.31
redis.port4=7003
redis.password4=
redis.host5=192.168.139.31
redis.port5=7004
redis.password5=
redis.host6=192.168.139.31
redis.port6=7005
redis.password6=
redis.minIdle=1
redis.maxIdle=300
redis.maxActive=600
redis.maxWait=1000
redis.testOnBorrow=true
spring.redis.cluster.max-redirects= 3
#理论上应该是可以用这个配置的,但是没啥头绪,求指教。
#
spring.redis.cluster.nodes=
xml version="1.0" encoding= "UTF-8"?>
<
beans
xmlns
=
"http://www.springframework.org/schema/beans"
xmlns:xsi
=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:context
=
"http://www.springframework.org/schema/context"
xmlns:p
=
"http://www.springframework.org/schema/p"
xsi:schemaLocation
=
"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"
>
<
bean
id
=
"clusterRedisNodes1"
class
=
"org.springframework.data.redis.connection.RedisNode"
>
<
constructor-arg
value
=
"${redis.host1}"
/>
<
constructor-arg
value
=
"${redis.port1}"
type
=
"int"
/>
bean
>
<
bean
id
=
"clusterRedisNodes2"
class
=
"org.springframework.data.redis.connection.RedisNode"
>
<
constructor-arg
value
=
"${redis.host2}"
/>
<
constructor-arg
value
=
"${redis.port2}"
type
=
"int"
/>
bean
>
<
bean
id
=
"clusterRedisNodes3"
class
=
"org.springframework.data.redis.connection.RedisNode"
>
<
constructor-arg
value
=
"${redis.host3}"
/>
<
constructor-arg
value
=
"${redis.port3}"
type
=
"int"
/>
bean
>
<
bean
id
=
"clusterRedisNodes4"
class
=
"org.springframework.data.redis.connection.RedisNode"
>
<
constructor-arg
value
=
"${redis.host4}"
/>
<
constructor-arg
value
=
"${redis.port4}"
type
=
"int"
/>
bean
>
<
bean
id
=
"clusterRedisNodes5"
class
=
"org.springframework.data.redis.connection.RedisNode"
>
<
constructor-arg
value
=
"${redis.host5}"
/>
<
constructor-arg
value
=
"${redis.port5}"
type
=
"int"
/>
bean
>
<
bean
id
=
"clusterRedisNodes6"
class
=
"org.springframework.data.redis.connection.RedisNode"
>
<
constructor-arg
value
=
"${redis.host6}"
/>
<
constructor-arg
value
=
"${redis.port6}"
type
=
"int"
/>
bean
>
<
bean
id
=
"redisClusterConfiguration"
class
=
"org.springframework.data.redis.connection.RedisClusterConfiguration"
>
<
property
name
=
"maxRedirects"
value
=
"${spring.redis.cluster.max-redirects}"
>
property
>
<
property
name
=
"clusterNodes"
>
<
set
>
<
ref
bean
=
"clusterRedisNodes1"
/>
<
ref
bean
=
"clusterRedisNodes2"
/>
<
ref
bean
=
"clusterRedisNodes3"
/>
<
ref
bean
=
"clusterRedisNodes4"
/>
<
ref
bean
=
"clusterRedisNodes5"
/>
<
ref
bean
=
"clusterRedisNodes6"
/>
set
>
property
>
bean
>
<
bean
id
=
"poolConfig"
class
=
"redis.clients.jedis.JedisPoolConfig"
>
<
property
name
=
"minIdle"
value
=
"${redis.minIdle}"
/>
<
property
name
=
"maxIdle"
value
=
"${redis.maxIdle}"
/>
<
property
name
=
"maxTotal"
value
=
"${redis.maxActive}"
/>
<
property
name
=
"maxWaitMillis"
value
=
"${redis.maxWait}"
/>
<
property
name
=
"testOnBorrow"
value
=
"${redis.testOnBorrow}"
/>
bean
>
<
bean
id
=
"jedisConnectionFactory"
class
=
"org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
p:use-pool
=
"true"
>
<
constructor-arg
index
=
"0"
ref
=
"redisClusterConfiguration"
/>
<
constructor-arg
index
=
"1"
ref
=
"poolConfig"
>
constructor-arg
>
bean
>
<
bean
id
=
"stringRedisSerializer"
class
=
"org.springframework.data.redis.serializer.StringRedisSerializer"
/>
<
bean
id
=
"jdkRedisSerializer"
class
=
"org.springframework.data.redis.serializer.JdkSerializationRedisSerializer"
/>
<
bean
id
=
"redisTemplate"
class
=
"org.springframework.data.redis.core.RedisTemplate"
p:connectionFactory-ref
=
"jedisConnectionFactory"
p:keySerializer-ref
=
"stringRedisSerializer"
p:hashKeySerializer-ref
=
"stringRedisSerializer"
p:valueSerializer-ref
=
"jdkRedisSerializer"
p:hashValueSerializer-ref
=
"jdkRedisSerializer"
/>
beans
>