关于springboot整合redis,失败踩坑记录

1.环境要求:

       1. redis配置文件redis.conf要求:

                1.protected-mode no

                2.注释掉bind 127.0.0.1

                3.设置timeout 不为0 

        2.vm与主机能互相ping通

        3.虚拟机上开放了端口,各种虚拟机的开发方式不同,百度指令开发即可

2.springboot连接时要求在application.yml配置redis正确的服务器ip,timeout时间不为0

3.springboot2.x中使用依赖lettuce,且lettuce不发心跳检测,而springboot1.x用的依赖是jedis,

这个会报io.lettuce的异常,

springboot2.x原版:

 springboot旧版依赖:

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

解决方式:

        修改pom.xml,在启动器依赖上替换:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-redis</artifactId>
    <exclusions>
        <exclusion>
            <groupId>io.lettuce</groupId>
            <artifactId>lettuce-core</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>redis.clients</groupId>
    <artifactId>jedis</artifactId>
</dependency>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值