1、在pom.xml文件中添加依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
<version>1.4.7.RELEASE</version>
</dependency>
2、创建resources/config/redis.properties配置文件
redis.properties文件内容如下:
#哨兵模式
#多个使用,分隔
redis.nodes=10.135.16.164:26379
redis.masterName=GMDCEQ-dev
redis.password=Haier,123
redis.maxTotal=10000
redis.maxIdle=100
redis.minIdle=50
redis.timeout=30000
3、创建RedisConfig.java,redis的配置类
package com.haier.gmdc.biprodweb.redisservice;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.data.redis.connection.RedisNode;
import org.springframe