zoukankan      html  css  js  c++  java
  • 解决@Autowire在springboot启动是报No qualifying bean的问题

    针对RedisTemplate封装了一个RedisUtils类,在调用时使用@Autowire注入此类,出现报错,内容如下

    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.popmart.testcontainer.testcase.OmsTest':
    Unsatisfied dependency expressed through field 'redisUtils'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.popmart.config.redis.RedisUtils' available:
    expected at least 1 bean which qualifies as autowire candidate.
    Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

    解决思路:

    1.根据保存分析原因:从报错信息无法扫描到redisUtils这个bean,如果@Autowire使用注释进行配置,则可能会缺少cn.itcast.crm.service.BaseDictService实现的注释(@Service或@Component等)。

    2.在RedisUtils类尝试着增加了@Service或@Component后问题解决,增加了@server注解后springboot启动可扫描到此bean。

  • 相关阅读:
    MIME协议(一) -- RFC822邮件格式
    生活
    面向对象设计的SOLID原则、迪米特法则
    策略模式
    asp.net Json序列化
    简单工厂模式
    CSS响应式布局实例
    CSS响应式网站开发
    mysql 记录根据日期字段倒序输出
    IE下JS保存图片
  • 原文地址:https://www.cnblogs.com/yull/p/14216315.html
Copyright © 2011-2022 走看看