SpringBoot集成Redis 启动报错

SpringBoot集成Redis 启动报错_第1张图片
SpringBoot启动报错:Field redisTemplate in com.test.redis.controller.TestController required a bean of type ‘org.springframework.data.redis.core.RedisTemplate’ that could not be found.

报错信息:容器中没有找到RedisTemplate????按理说springboot应该帮我们注入了啊,赶紧看一眼自动配置类:RedisAutoConfiguration
SpringBoot集成Redis 启动报错_第2张图片
发现springboot确实帮我们注入了,但是泛型中定义的是RedisTemplate

所以解决方法有啦
将注入的RedisTemplate改成下面这种形式
在这里插入图片描述
顺利启动!!!!

你可能感兴趣的:(java)