您的位置:首页 > 数据库 > Redis

springboot集成redis集群(带密码并序列化)

2017-08-29 10:24 751 查看

pom配置

常用的springboot配置就不贴了,下面只贴redis有关的

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


application.properties配置

spring.redis.database=0
spring.redis.cluster.nodes=192.168.248.146:7001,192.168.248.146:7002,192.168.248.146:7003,192.168.248.146:7004,192.168.248.146:7005,192.168.248.146:7006
spring.redis.password=11111
spring.redis.pool.max-active=8
spring.redis.pool.max-wait=-1
spring.redis.pool.max-idle=8
spring.redis.pool.min-idle=0
spring.redis.timeout=0


序列化

为什么要序列化?贴个图大家就懂了。这是楼主没有序列化的时候,插入q和t12个key的情况



在客户端里面,用命令 get q 或者 get t1 确实可以取出来,但是用代码获取一直为null

当序列化后,插入sjz的情况



用代码就可以取出来了哦
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息