关于Spring 配置redis出现的冲突导致无法使用

我在springboot项目中采用  --RedisTemplate--来配置redis的时候一直出现,方法内部报错。

 

具体原因

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.0.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.8.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

(springboot 的maven依赖包中默认的springboot依赖)

Mave使用的spring-boot-starter-parent会使项目加入一些默认配置。这个parent提供了以下特性:

默认使用Java 8
使用UTF-8编码
一个引用管理的功能,在dependencies里的部分配置可以不用填写version信息,这些version信息会从spring-boot-dependencies里得到继承。
识别过来资源过滤(Sensible resource filtering.)
识别插件的配置(Sensible plugin configuration (exec plugin, surefire, Git commit ID, shade).)
能够识别application.properties和application.yml类型的文件,同时也能支持profile-specific类型的文件(如: application-foo.properties and application-foo.yml,这个功能可以更好的配置不同生产环境下的配置文件)。
maven把默认的占位符${…​}改为了@..@(这点大家还是看下原文自己理解下吧,我个人用的也比较少 
since the default config files accept Spring style placeholders (${…​}) the Maven filtering is changed to use @..@ placeholders (you can override that with a Maven property resource.delimiter).)

导致在配置 spring-boot-starter-data-redis依赖 RedisTemplate方式控制redis的时候会出现版本配置问题

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

对应的jar包依赖只能是  1.5.8版本的,当默认新建的版本是2.0.以上时会出现配置异常

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.8.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值