admin管理员组文章数量:1794759
解决Consider defining a bean of type org.springframework.data.redis.core.RedisTemplate in your configu
在学习Springboot+redis整合demo时,搭建好项目启动时报如下错误:
*************************** APPLICATION FAILED TO START ***************************
Description:
Field redisTemplate in jypay.spring_cloud_consul_comsumer.controller.TestController required a bean of type 'org.springframework.data.redis.core.RedisTemplate' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.data.redis.core.RedisTemplate' in your configuration.
我查看项目的定义RedisTemplate的类(RedisConfig.java)定义和写法上没错。controller的使用TestController.java使用了RedisTemplate,并且使用@Autowired注入也没错。怎么会出现这种错误呢?于是在网上搜索看别人blog说是启动类ConsuleConsumerApplication.java没有扫描到RedisConfig.java的注解。我添加了@ComponentScan就解决了。如下截图:
其实也可以把需扫描的类放到springboot的启动类同一个包也可以。看自己的项目需求来定了。
本文标签: orgspringframeworktypedefiningbean
版权声明:本文标题:解决Consider defining a bean of type org.springframework.data.redis.core.RedisTemplate in your configu 内容由林淑君副主任自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.xiehuijuan.com/baike/1686551998a80988.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论