Spring boot 集成Redis的步驟以下:redis
1.在pom.xml中配置相關的jar依賴;spring
<!--加載spring boot redis包 -->app
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId></dependency>2.在Springboot核心配置文件application.properties中配置redis鏈接信息:spring.redis.host=127.0.0.1spring.redis.port=6379spring.redis.password=1234563.配置了上面的步驟,Spring boot將自定配置RedisTemplate,在須要操做redis的類中注入redisTemplate;在使用的類中注入:@Autowriedprivate RedisTemplate<String,String> redisTemplate;@Atuowriedprivate RedisTemplate<Object,Object> redisTemplate;spring boot幫咱們注入的RedisTemplate類,泛型裏面只能寫<String,String>,<Object,Object>