Action: Consider marking one of the beans as @Primary, updating the consumer to accept multiple bean

  • Post author:
  • Post category:其他


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

报错可能是因为使用@Autowired注解,但是该接口下有多个实现,导致spring容器不知道将那个子类注入进来

我出现该问题是一个接口继承另一个接口。

解决方案为:接口不要继承,直接全部copy到新接口上,在新的实现类那边用组合的方式即可,如下

可能还会有其他问题导致该报错,比如Mybatis多数据源导致的,不知道去装载那个database,具体可以参照网上大神的帖子



版权声明:本文为lxylance原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。