Spring中的Redis配置

的pom.xml中:

< dependency >
     < groupId > org.springframework.data groupId >
     < artifactId > spring-data-redis artifactId >
     < version > 1.4.1.RELEASE version >
 dependency >
 < dependency >
     < groupId > redis .clients groupId >
     < artifactId > jedis artifactId >
     <> 2.6.2 version >
 dependency >

的applicationContext-redis.xml中:

< beans xmlns =“http://www.springframework.org/schema/beans”
 xmlns:context =“http://www.springframework.org/schema/context” xmlns:p =“http://www.springframework .org / schema / p“
 xmlns:aop =”http://www.springframework.org/schema/aop“ xmlns:tx =”http://www.springframework.org/schema/tx“
 xmlns:xsi =” http://www.w3.org/2001/XMLSchema-instance “
 的xsi :的schemaLocation =” http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-豆类,4.0.xsd
                               http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
    http://www.springframework.org/schema/aop http:/ /www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0 .xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd“ >
 <! - 连接池的配置 - >
 < bean id =“jedisPoolConfig” class =“redis.clients.jedis.JedisPoolConfig” >
 <! - 最大连接数 - >
 < property name =“maxTotal” value =“$ {redis。maxTotal}“ />

                                <! - 最大等待时间 - >
 < property name =“maxWaitMillis” value =“$ {redis.maxWaitMillis}” />
 <! - 获取连接时检查有效性 - >
 < property name =“testOnBorrow” value =“$ {redis.testOnBorrow}” />
     bean >
 <! -  Jedis连接工厂 - >
 < bean id =“jedisConnectionFactory”
 class =“org.springframework.data.redis.connection.jedis.JedisConnectionFactory” >
 <! - 连接池的配置 - >
 < property name =“poolConfig”ref =“jedisPoolConfig” />
 <! - 主机地址 - >
                        
                                                  < property name =“hostName” value =“$ {redis.hostName}” />
 <! - 端口 - >
 < property name =“port” value =“$ {redis.port}” />
 <! -是否启用连接池 - >
 < property name =“usePool” value =“$ {redis.usePool}” />
     bean >
 <! -  String类型的RedisTemplate模板 - >
 < bean id =“stringRedisTemplate” class =“org.springframework.data.redis.core.StringRedisTemplate” >
        < constructor-arg index =“0”                                
        ref =“jedisConnectionFactory” />
     bean >
 beans >
redis.properties中:

redis.maxTotal = 200
 redis.maxWaitMillis = 1000
 redis.testOnBorrow = true
 redis.hostName = 192.168.206.101
 redis.port = 6379
 redis.usePool = true

你可能感兴趣的:(Redis,java,spring,redis,spring中的redis,redis配置)