SpringBoot集成redis报错
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘org.springframework.data.redis.core.RedisTemplate<java.lang.String, java.lang.String>’ available: expected at least 1 bean which qualifies as autowire candidate
使用的pom依赖文件:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
Yml配置文件
redis:
host: localhost
port: 6379
password:
jedis:
pool:
max-active: 8
max-wait: -1
max-idle: 500
min-idle: 0
lettuce:
shutdown-timeout: 0
报错原因:使用的是Test,没有加上注解: @RunWith(SpringRunner.class) @SpringBootTest
加上后,问题解决!
|