SpringBoot 整合redis

来源:互联网 发布:知乎 瞎扯 编辑:程序博客网 时间:2024/05/18 00:58

SpringBoot整合redis

引入依赖

<dependency>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot-starter-data-redis</artifactId></dependency>

SpringBoot的依赖管理引入和redis相关的依赖,然后添加xml配置

<bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig">    <property name="maxIdle" value="${redis.maxIdle}" />    <property name="maxWaitMillis" value="${redis.maxWait}" />    <property name="testOnBorrow" value="${redis.testOnBorrow}" /></bean><bean id="connectionFactory"  class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory" >    <property name="poolConfig" ref="poolConfig" />    <property name="port" value="${redis.port}" />    <property name="hostName" value="${redis.host}" />    <property name="password" value="${redis.password}" />    <property name="timeout" value="${redis.timeout}"/></bean><bean id="redisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate" >    <property name="connectionFactory" ref="connectionFactory" /></bean >
原创粉丝点击