Spring boot使用Redis时,报错,有redisTemplate和stringRedisTemplate两个bean?

Error starting ApplicationContext. To display the auto-configuration report re-run your application with ‘debug‘ enabled.
2017-05-13 20:11:30.651 ERROR 1869 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of method setRedis in cn.andhub.authorization.manager.impl.RedisTokenManager required a single bean, but 2 were found:
    - redisTemplate: defined by method ‘redisTemplate‘ in class path resource [org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration$RedisConfiguration.class]
    - stringRedisTemplate: defined by method ‘stringRedisTemplate‘ in class path resource [org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration$RedisConfiguration.class]

Action:

Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed

 

解决办法:

spring-boot-starter-parent最新版本应该是2.0.0,就会报这个错,更改如下:
<parent>

    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.6.RELEASE</version>  //降低parent版本
    <relativePath/> <!-- lookup parent from repository -->
</parent>

原文地址:https://www.cnblogs.com/Andrew520/p/8684544.html

时间: 2024-11-08 14:57:47

Spring boot使用Redis时,报错,有redisTemplate和stringRedisTemplate两个bean?的相关文章

【spring boot】mybatis启动报错:Consider defining a bean of type &#39;com.newhope.interview.dao.UserMapper&#39; in your configuration.

启动报错: 2018-02-24 22:41:00.442 WARN 2952 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error c

Spring Boot项目Maven Build报错的解决方法

问题1, [ERROR]Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.21.0:test (default-test) on project motherBuyBoot: There are test failures. [ERROR] Please refer to D:\web\motherbuy\target\surefire-reports for the individual test r

Spring Boot整合Elasticsearch启动报错

如果你遇见下面的错误,很可能是你的springboot和es版本关系不对应 ERROR 14600 --- [ main] .d.e.r.s.AbstractElasticsearchRepository : failed to load elasticsearch nodes : org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#

spring boot,gradle,redis

今天做spring boot/gradle/redis相关的项目,遇到若干问题,记录如下: spring boot  org.springframework.session.data.redis.RedisFlushMode 这个报错是与redis服务器连接的问题,查看一下在application.properties里写的redis服务器IP是不是错了,改正即可;或者redis服务器启用了protected-mode,运行Redis时使用命令: nohup redis-server --pro

Spring Boot学习笔记——Spring Boot与Redis的集成

一.添加Redis缓存 1.添加Redis起步依赖 在pom.xml中添加Spring Boot支持Redis的依赖配置,具体如下: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-redis</artifactId> <version>1.4.7.RELEASE</version> </

Spring Boot 整合mybatis时遇到的mapper接口不能注入的问题

现实情况是这样的,因为在练习spring boot整合mybatis,所以自己新建了个项目做测试,可是在idea里面mapper接口注入报错,后来百度查询了下,把idea的注入等级设置为了warning,至于怎末设置可以自行百度,这里不再赘述,但是接下来spring boot能够运行起来,但是通过浏览器访问的时候,就会报错,后来也是经过多方查询,发现了问题的原因,特此记录一下: spring  boot整合mybatis时,要将mapper装配到spring容器中,要在mapper接口中加上@M

Spring Boot整合Redis

一.Spring Boot对Redis的支持 Spring对Redis的支持是使用Spring Data Redis来实现的,一般使用Jedis或者lettuce(默认),Java客户端在 org.springframework.boot.autoconfigure.data.redis(Spring Boot 2.x) 中redis的自动配置 AutoConfigureDataRedis RedisAutoConfiguration提供了RedisTemplate与StringRedisTem

REDIS持久化报错失败

redis log报错: [7666] 15 Jan 00:22:36.028 # Error moving temp DB file on the final destination: Invalid cross-device link [1937] 15 Jan 00:22:36.513 # Background saving error [1937] 15 Jan 00:22:36.614 * 1 changes in 900 seconds. Saving... [7679] 15 Ja

Spring Boot使用redis实现数据缓存

基于Spring Boot 1.5.2.RELEASE版本,一方面验证与Redis的集成方法,另外了解使用方法. 集成方法 配置依赖 修改pom.xml,增加如下内容. <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> 配置Redis