• spring配置redis


    <?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:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">


    <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
    <property name="maxTotal" value="300"/> <!-- 控制一个pool可分配多少个jedis实例 -->
    <property name="maxIdle" value="100" /> <!-- 控制一个pool最多有多少个状态为idle(空闲)的jedis实例 -->
    <property name="maxWaitMillis" value="2000" /> <!-- 表示当borrow一个jedis实例时,最大的等待时间,如果超过等待时间,则直接抛出JedisConnectionException -->
    <property name="testOnBorrow" value="true"/>
    <property name="testOnReturn" value="true"/>
    </bean>
    <!-- redis的连接池pool,不是必选项:timeout/password -->
    <bean id="jedisConnectionFactory"
    class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
    <property name="hostName" value="${redis.host}" />
    <property name="port" value="${redis.port}" />
    <property name="password" value="${redis.passWord}" />
    <property name="poolConfig" ref="jedisPoolConfig" />
    </bean>


    <bean id="stringRedisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate">
    <property name="connectionFactory">
    <ref bean="jedisConnectionFactory" />
    </property>
    </bean>
    <!-- 配置springRedis -->
    <bean id="springRedis" class="com.inborn.inshop.common.redis.SpringRedis">
    <property name="redisKeyPrefix" value="${redis.key.prefix}" />
    <property name="stringRedisTemplate">
    <ref bean="stringRedisTemplate" />
    </property>
    </bean>

    </beans>

  • 相关阅读:
    Docker之4---Docker存储卷与容器卷详解
    Docker之3---java业务镜像制作
    Docker之2---Dockerfile详解
    devops持续集成
    云计算之4---Cockpit
    云计算之3---OpenStack
    云计算之2---KVM
    云计算之1---介绍
    自动化运维工具-Ansible之7-roles
    mycat读写分离
  • 原文地址:https://www.cnblogs.com/lvgg/p/6655359.html
Copyright © 2020-2023  润新知