Spring Boot+redis

1.整合单机版

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

  application.properties配置:

    spring.redis.host=192.168.66.66
    spring.redis.port=6379

2.整合redis集群

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

  application.properties配置:spring.redis.cluster.nodes=192.168.66.7001,192.168.66.7002,192.168.66.7003,192.168.66.7004,192.168.66.7005

  src/main/java 下编写配置类:

  在service实现类中注入成员变量@Autowired private JedisCluster jedisCluster.

   jedisCluster.set("key","value");设置redis集群key的值是value

  或者@Autowired private RedisTemplate redisTemplate; boundValueOps

posted @ 2018-04-18 11:16  袋子里的袋鼠  阅读(131)  评论(0编辑  收藏  举报